Hello Experts,
I have a tabcontrol and I place datagrid inside a tabcontrol... But I could not focus that Datagrid at the load event ... Focus means I couldn't navigate through keyboard into it... I'm getting this problem only inside of the tab control otherwise it works fine...
My xaml code as follws...
My C# code as follows
namespace WpfApplication12 { /// /// Interaction logic for MainWindow.xaml /// public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); Loaded += new RoutedEventHandler(MainWindow_Loaded); }
void MainWindow_Loaded(object sender, RoutedEventArgs e) {
SqlConnection sqlcon = new SqlConnection("server=ibmserver;uid=sa;pwd=zillion;database=ecdslxyz20102011"); SqlCommand sqlcmd = new SqlCommand("select * from account", sqlcon); SqlDataAdapter sqldac = new SqlDataAdapter(sqlcmd); DataSet ds = new DataSet(); sqldac.Fill(ds, "Test"); grd_boview.ItemsSource = ds.Tables["Test"].DefaultView; grd_boview.Focus(); grd_boview.SelectedIndex = 0; } } }
(1) Please remember note that focus means I couldn't navigate a datagrid through keyboard
(2) It should be in load event......Because it works fine in other events...
(3) Datagrid should be placed inside a tab control... Because it works fine outside a tab control.....
I hope u wil help me...
Thanks in Advance