Hi all,
I am using two textbox control and two checkbox control named as textbox1 , textbox2,checkbox1 and checkbox2. Actually what i want to give functionality in my code, when i checked Checkbox1 then my texbox1 should get focus.and same for another checkbox2. i am using below code for checkebox on checked event :
DispatcherPriority.ContextIdle,
new Action(delegate()
{
textbox1 .Focus();
}));
if i checked individually then it works fine but after got focus on textbox1. if i checked checkbox2 my textbox2 is not going to focus(viceversa).
Please help me
Thanks
Ck NitinPosted Apr 11, 2013, 6:27 AM
Try to use this code..
private void radioButton1_Checked(object sender, RoutedEventArgs e)
{
radioButton1.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => SetFocus()));
}
private void radioButton2_Checked(object sender, RoutedEventArgs e)
{
radioButton2.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => SetFocus()));
}
private void SetFocus()
{
if (radioButton1.IsChecked.Equals(true))
textBox1.Focus();
else if(radioButton2.IsChecked.Equals(true))
textBox2.Focus();
}