Greetings,
We're starting to transition our legacy C# apps from earlier versions to
VS2008 versions.
Many of our apps allow the user to select a row from a DataGrid into a 'Data
Edit' area composed of Text, Combo, etc boxes that contain the individual
columns of the DataGrid row.
To extract information from the user selected DataGrid row we use the
following code ....
Given a DataGrid / DataGridView named "dgResults"
string sSelectedDirID = null;
string sSelectedGridID = null;
DataRowView oDrvSelectedGri dRow = null;
try
{
oDrvSelectedGri dRow =
(DataRowView)th is.BindingConte xt[dgResults.DataS ource,
dgResults.DataM ember].Current;
sSelectedDirID = oDrvSelectedGri dRow["Dir_id"].ToString().Tri m();
sSelectedGridID = oDrvSelectedGri dRow["Grid_id"].ToString().Tri m();
}
catch { return;}
The best translation of the code above for a DataGridView seems to be
something like
string sSelectedDirID = null;
string sSelectedGridID = null;
DataRowView oDrvSelectedGri dRow = null;
try
{
oDrvSelectedGri dRow = this.dgResults. CurrentRow.Data BoundItem AS
DataRowView;
sSelectedDirID = oDrvSelectedGri dRow["Dir_id"].ToString().Tri m();
sSelectedGridID = oDrvSelectedGri dRow["Grid_id"].ToString().Tri m();
}
catch { return;}
Anyone have a better approach ?
Thanks in advance.
Barry in Oregon.