C# 我的文本框正在清除,无法隐式转换类型
我所要做的只是在点击按钮时清除文本框。我得到这个错误 “错误2无法将类型'string'隐式转换为'System.Windows.Forms.TextBox'C:\Users\Ed\Downloads\BT1\u B\BT1\u B\Form1.cs 108 36 BT1\u B” "C# 我的文本框正在清除,无法隐式转换类型,c#,onclick,textbox,C#,Onclick,Textbox,我所要做的只是在点击按钮时清除文本框。我得到这个错误 “错误2无法将类型'string'隐式转换为'System.Windows.Forms.TextBox'C:\Users\Ed\Downloads\BT1\u B\BT1\u B\Form1.cs 108 36 BT1\u B” " 但请保持问题的具体性,在寻求帮助之前进行一些研究。请不要在标题末尾添加“C#”之类的内容。这就是标签的用途。你能发布相关的,并且只有相关的代码吗?理解,我认为最好给出整个图片。第108行是什么代码?108-txt
但请保持问题的具体性,在寻求帮助之前进行一些研究。请不要在标题末尾添加“C#”之类的内容。这就是标签的用途。你能发布相关的,并且只有相关的代码吗?理解,我认为最好给出整个图片。第108行是什么代码?108-txt_incoming_message.Text=“”;在Visual Studio c#2008中,文本的“xt”下面有一条蓝色的曲线,你确定这是一个文本框吗?请(如果可能)发布您创建文本框的设计器类的代码和/或指向formprivate System.Windows.Forms.textbox txt_传入消息图像的链接;这个答案是正确的,你不可能得到同样的错误。我发现这表明有一个线程问题。你们是一个令人难以置信的善良和聪明。谢谢大家,祝大家万事如意。
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();
}
}
}
private void btn_clear_Click(object sender, EventArgs e)
{
txt_incoming_message.Text = "";
}