如何在我的texbox 中顯示我的form2groupbox 單選按鈕(3 個單選按鈕,我只能顯示一個)中的選定專案。Form1
這是我的問題,因為我只知道要顯示的代碼 1. if statments 不起作用。
表格1:
public void button5_Click(object sender, EventArgs e)
{
Form2 fr2 = new Form2();
textBox1.Text = fr2.receivet(textBox1.Text, fr2.radioButton1);
}
表格2:
internal string receivet(string textBox1, RadioButton radio)
{
return textBox1 = radio.Text;
}
uj5u.com熱心網友回復:
不需要像receivet那樣創建方法,可以直接從Form物件中獲取RadioButton
public void button5_Click(object sender, EventArgs e)
{
Form2 fr2 = new Form2();
string radioTxt = ""
if (fr2.RadioButton1.Checked)
{
radioTxt = fr2.RadioButton1.Text
}
else if (fr2.RadioButton2.Checked)
{
radioTxt = fr2.RadioButton2.Text
}
else if (fr2.RadioButton3.Checked)
{
radioTxt = fr2.RadioButton3.Text
}
textBox1.Text = radioTxt;
}
uj5u.com熱心網友回復:
在您的代碼中,您創建一個新的 Form2 實體并獲取它的值。您需要呼叫顯示的 Form2 實體的函式(并將其設定為 public 修飾符)。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/522140.html
標籤:C#表格窗体设计器
