0
我在我的windows phone 7應用程序中有一個窗體,其中包含幾個文本框和一個單選按鈕。我想重置單擊復位按鈕上的文本框和單選按鈕的值。我能夠清除文本框,但不知道如何清除單選按鈕的值。請幫助:如何重置使用c的windows phone 7應用程序中的單選按鈕的值#
我的形式是:
<TextBox GotFocus="OnGotFocus" Canvas.Left="6" Canvas.Top="6" Height="74" Name="name" Text="*Name" Width="453" BorderThickness="0"/>
<TextBox GotFocus="OnGotFocus1" Canvas.Left="6" Canvas.Top="66" Height="74" Name="age" Text="*Age" Width="453" BorderThickness="0" />
<TextBlock Canvas.Left="20" Canvas.Top="157" Height="44" Name="gen" Text="Gender" Foreground="Black" FontFamily="Verdana" FontSize="24" Width="134" />
<RadioButton Canvas.Left="139" Canvas.Top="157" FontStyle="Italic" Foreground="Black" Content="Male" Height="71" Name="male" Width="154" />
<RadioButton Canvas.Left="139" Canvas.Top="207" FontStyle="Italic" Foreground="Black" Content="Female" Height="71" Name="fem" Width="140" />
<TextBox GotFocus="OnGotFocus2" Canvas.Left="6" Canvas.Top="267" Height="74" Name="sadd" Text="*Street Address" Width="453" BorderThickness="0"/>
<TextBox GotFocus="OnGotFocus3" Canvas.Left="6" Canvas.Top="327" Height="74" Name="cadd" Text="*City Address" Width="453" BorderThickness="0"/>
<TextBox GotFocus="OnGotFocus4" Canvas.Left="6" Canvas.Top="387" Height="74" Name="eadd" Text="*Email Address" Width="453" BorderThickness="0"/>
<TextBox GotFocus="OnGotFocus5" Canvas.Left="6" Canvas.Top="447" Height="74" Name="phn" Text="*Phone" Width="453" BorderThickness="0"/>
<TextBox GotFocus="OnGotFocus6" Canvas.Left="6" Canvas.Top="507" Height="74" Name="zip" Text="*Zip Code" Width="453" BorderThickness="0"/>
我對重新上點擊復位按鈕的代碼是:
private void reset_Click(object sender, RoutedEventArgs e)
{
name.Text = "";
age.Text = "";
sadd.Text = "";
cadd.Text = "";
eadd.Text = "";
phn.Text = "";
zip.Text = "";
}
請補充一點,我要在這裏補充重置單選按鈕的代碼
現在點擊提交按鈕,如果我想檢查是否已選擇男性或女性,我該怎麼做。對於文本框我做下面的代碼:
private void submit_Click(object sender, RoutedEventArgs e)
{
if (name.Text == "")
{
MessageBox.Show("Please Enter the name");
name.Focus();
}
}
請看我編輯的代碼。我想驗證該領域,即是否選擇男性或女性。 – bhaku
檢查編輯。 –
和提示,不應使用name.Text ==「」,而應使用name.Text == String.Empty。同樣也適用於分配。 –