Z
zleug
Guest
Hi All.
The TabControl has three TabItems. Each TabItem contains DataGrid. And I would like to populate DataGrid in case if according TabItem selected.
private void Window_Loaded(object sender, RoutedEventArgs e)
{
SetA_DG();
}
public void SetA_DG()
{
var sourcea UIAdapter.GetSourceA();
DataGrid_A.ItemsSource = sourcea;
}
public void SetB_DG()
{
var sourceb UIAdapter.GetSourceB();
DataGrid_B.ItemsSource = sourceb;
}
public void SetC_DG()
{
var sourcec UIAdapter.GetSourceC();
DataGrid_C.ItemsSource = sourcec;
}
private void ABC_TC_SelectedChenged(object sender, SelectionChangedEventArgs e)
{
var sTabItem = ABC_TC.SelectedItem as TabItem;
switch (sTabItem.Name)
{
case "A_TI":
SetA_DG();
break;
case "B_TI":
SetB_DG();
break;
case "C_TI":
SetC_DG();
break;
}
}
When I run application I get error message: System.NullReferenceException: 'Object reference not set to an instance of a object.' A_DG was null.
When I leave not commented only case "A_TI" and rest case statements are commented application running normally and A_DG is populated.
How to fix the problem?
Thanks.
Continue reading...
The TabControl has three TabItems. Each TabItem contains DataGrid. And I would like to populate DataGrid in case if according TabItem selected.
private void Window_Loaded(object sender, RoutedEventArgs e)
{
SetA_DG();
}
public void SetA_DG()
{
var sourcea UIAdapter.GetSourceA();
DataGrid_A.ItemsSource = sourcea;
}
public void SetB_DG()
{
var sourceb UIAdapter.GetSourceB();
DataGrid_B.ItemsSource = sourceb;
}
public void SetC_DG()
{
var sourcec UIAdapter.GetSourceC();
DataGrid_C.ItemsSource = sourcec;
}
private void ABC_TC_SelectedChenged(object sender, SelectionChangedEventArgs e)
{
var sTabItem = ABC_TC.SelectedItem as TabItem;
switch (sTabItem.Name)
{
case "A_TI":
SetA_DG();
break;
case "B_TI":
SetB_DG();
break;
case "C_TI":
SetC_DG();
break;
}
}
When I run application I get error message: System.NullReferenceException: 'Object reference not set to an instance of a object.' A_DG was null.
When I leave not commented only case "A_TI" and rest case statements are commented application running normally and A_DG is populated.
How to fix the problem?
Thanks.
Continue reading...