我是C#的新手,我正在創建Q + A Forms應用程序。我在「txt.AcceptsReturn = true;」一行中收到「無法檢測到的代碼」警告。我曾嘗試在行上使用#pragma警告禁用,但它不會執行那段代碼。 任何幫助,將不勝感激,謝謝!檢測到無法訪問的代碼c#表格
namespace WindowsFormsApplication11
{
public partial class c1l1 : Form
{
int cLeft = 1;
public c1l1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
TextBox t= new TextBox();
t.Text = "Enter the question for Category 1, Level 1";
String t2;
t2 = t.Text;
MessageBox.Show(t2);
AddNewTextBox();
}
public System.Windows.Forms.TextBox AddNewTextBox()
{
System.Windows.Forms.TextBox txt = new System.Windows.Forms.TextBox();
this.Controls.Add(txt);
txt.Top = cLeft * 25;
txt.Left = 100;
txt.Text = "TextBox " + this.cLeft.ToString();
cLeft = cLeft + 1;
return txt;
txt.AcceptsReturn = true;
KeyEventArgs e;
if (txt.Text != null && e.KeyCode == Keys.Enter)
{
txt.Visible = false;
}
}
}
}
你是從方法上面該線路的線路返回。它永遠不會被達到,因爲你已經返回。 – 2014-11-04 16:21:41
返回關鍵字信號函數的結尾 – 2014-11-04 16:24:28
該函數的意圖不清楚。 – ja72 2014-11-04 18:03:16