2012-03-14 3 views
1

버튼 클릭시 텍스트 상자를 지우는 것입니다. 이 오류를내 textbox.clear(); 오류가 발생했습니다

얻을 "암시 적으로 'System.Windows.Forms.TextBox'C로 유형 '문자열을'변환 할 수 없습니다 오류 2 : \ 사용자 \ 에드 \ 다운로드 \ BT1_B \ BT1_B \ Form1.cs를 (108) (36) BT1_B "

using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Text; 
using System.Windows.Forms; 
using System.Threading; 
using System.IO; 
using InTheHand; 
using InTheHand.Net; 
using InTheHand.Net.Sockets; 
using InTheHand.Net.Bluetooth; 


namespace BT1_B 
{ 
    public partial class Form1 : Form 
    { 
     Guid service = new Guid("{00001101-0000-1000-8000-00805F9B34FB}"); 
     BluetoothListener bl; 
     BluetoothClient bc; 
     bool radioAvailable = false; 
     bool listening = false; 
     delegate void SettbMessageReceivedCallback(string text); 

     public Form1() 
     { 
      InitializeComponent(); 
     } 

     private void Form1_FormClosing(object sender, FormClosingEventArgs e) 
     { 
      try 
      { 
       listening = false; 
       bl.Stop(); 
      } 
      catch 
      { 
      } 

     } 

     private void btn_listen_Click(object sender, EventArgs e) 
     { 
      try 
      { 
       BluetoothRadio.PrimaryRadio.Mode = RadioMode.Discoverable; 
       radioAvailable = true; 
      } 
      catch 
      { 
       MessageBox.Show("Please make sure Bluetooth is available"); 
      } 
      if (radioAvailable) 
      { 
       bl = new BluetoothListener(BluetoothService.SerialPort); 
       bl.Start(); 
       listening = true; 
       System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(ListenLoop)); 
       t.Start(); 
      } 
     } 
     private void ListenLoop() 
     { 
      try 
      { 
       while (listening) 
       { 
        bc = bl.AcceptBluetoothClient(); 
        StreamReader sr = new StreamReader(bc.GetStream()); 
        String message = sr.ReadLine(); 
        sr.Close(); 
        SettbMessageReceived(message); 
       } 
      } 
      catch 
      { 
      } 
     } 
     private void SettbMessageReceived(string text) 
     { 
      try 
      { 
       if (this.txt_incoming_message.InvokeRequired) 
       { 
        SettbMessageReceivedCallback d = new SettbMessageReceivedCallback(SettbMessageReceived); 
        this.Invoke(d, new object[] { text }); 
       } 
       else 
       { 
        this.txt_incoming_message.Text += text + "\r\n"; 
       } 
      } 
      catch (ThreadAbortException ex) 
      { 
      } 
     } 

     private void Form1_Load(object sender, EventArgs e) 
     { 

     } 

     private void btn_clear_Click(object sender, EventArgs e) 
     { 
      txt_incoming_message.Clear(); 
     } 
    } 
} 
+0

"C#"등을 제목 끝에 추가하지 마십시오. 그것이 바로 태그가있는 것입니다. –

+1

관련 *, 관련 * 코드 만 게시 할 수 있습니까? –

+0

전체 사진을 제공하는 것이 가장 바람직하다고 생각했습니다. –

답변

3
private void btn_clear_Click(object sender, EventArgs e) 
    { 
     txt_incoming_message.Text = ""; 
    } 

하지만 특정 질문을 유지하고, 도움을 요청하기 전에 몇 가지 조사를 해 주시기 바랍니다.

+0

그랬습니다. 나는 이것을 시도했지만 동일한 오류가 발생합니다. –

+0

확실한 텍스트 상자입니까? 텍스트 상자를 만든 디자이너 클래스의 게시물 코드 및/또는 양식 이미지에 대한 링크를 입력하십시오 ( –

+0

). private System.Windows.Forms.TextBox txt_incoming_message; –

관련 문제