P
PJHORNSA
Hi,
I am stuck on a problem with the datagrid control in Visual Studio
2003, using C#.
I have a main form with a datagrid, then a search screen that filters
the dataset from the grid. Well on the search screen I get the current
selected record's ID with this code:
BindingManagerBase b = this.BindingContext[Datatable1];
DataRowView rvCurrent = (DataRowView) b.Current;
DataRow row = rvCurrent.Row;
CurrID = int.Parse(row["ID"].ToString());
this.DialogResult = DialogResult.OK;
this.Close();
then back on the main form I use the ID to navigate to the correct
record with this code:
if (frmFind.DialogResult == DialogResult.OK)
{
for(int x=0;x<dataSetEmployee1.Employee.Rows.Count;x++)
{
if(dataSetEmployee1.Employee.Rows[x]["ID"].ToString() ==
frmFind.CurrentID.ToString())
{
dataGrid1.BindingContext[dataSetEmployee1,"Employee"].Position =
x;
break;
}
}
}
now this works fine but if I click on the datagrids header to change
the sorting. I get the wrong record.
If anyone can help please.
Thanx in advance
Paul
I am stuck on a problem with the datagrid control in Visual Studio
2003, using C#.
I have a main form with a datagrid, then a search screen that filters
the dataset from the grid. Well on the search screen I get the current
selected record's ID with this code:
BindingManagerBase b = this.BindingContext[Datatable1];
DataRowView rvCurrent = (DataRowView) b.Current;
DataRow row = rvCurrent.Row;
CurrID = int.Parse(row["ID"].ToString());
this.DialogResult = DialogResult.OK;
this.Close();
then back on the main form I use the ID to navigate to the correct
record with this code:
if (frmFind.DialogResult == DialogResult.OK)
{
for(int x=0;x<dataSetEmployee1.Employee.Rows.Count;x++)
{
if(dataSetEmployee1.Employee.Rows[x]["ID"].ToString() ==
frmFind.CurrentID.ToString())
{
dataGrid1.BindingContext[dataSetEmployee1,"Employee"].Position =
x;
break;
}
}
}
now this works fine but if I click on the datagrids header to change
the sorting. I get the wrong record.
If anyone can help please.
Thanx in advance
Paul