I am new to wpf, i m using a editable comboBox (for search purpose). When text in ComboBox is changed, below datagrid displays the search result. when any row from the datagrid is selected its values are displayed in textboxes for editing.
when i write something in combobox the realated row are displayed in the data grid.. but when i, click to select a row, application throws a nullreference exception.
My application worked correctly when the dataGrid refreshing logic was behind a button click.
the code for "SelectionChange" Event of the dataGrid is:
private void CategoryRowSelected(object sender, System.Windows.Controls.SelectedCellsChangedEventArgs e)
{
ClearForm();
if(CategoryDataGrid.SelectedItem!=null)
{
categoryMember = CategoryDataGrid.SelectedItem as CategoryTbl;
CategoryName.Text = categoryMember.CategoryName;
CategoryDescription.Text = categoryMember.CategoryDescription;
}
}
and code for the textChange event of ComboBox is:
private void RefreshDataGrid(object sender, System.Windows.Controls.TextChangedEventArgs e)
{
CategoryDataGrid.SelectedIndex = -1;
CategoryDataGrid.ItemsSource= Admin.RefreshCategoryDataGrid(NameCombo.Text);
}
I hope to get an answer sooon....