0
But if You use sorting or filtering in DataGrid use DataView instead of DataTable. The simple solution (not tested, when it works):
myDataGrid.DefaultView[myRow].Row[myField]
or more complicated - create Your own property in object inherited from DataGrid:
public DataView GridView
{
get
{
try { return (DataView)(this.ListManager.List); }
catch { return null; }
}
}
and use it:
myDataGrid.GridView[myRow].Row[myField]
0
Los_Calibra
First get the Row number of the selected row:
int gridRow = dataGrid1.CurrentCell.RowNumber
Next get the DateSource :
DataTable dt = ((DataSet)dataGrid1.DataSource).Tables["My_Table"];
Now get the value:
dt.Rows[gridRow]["Column_Name"]
Hope this Helps
0
When You select only one row (standard in DataGrid) it's quite good. Next - you may create inherited DataGrid and override select methods (with "new" keyword; usual overriding is impossible). Now I'm trying to do this. I use four methods:
public new void Select(int row){ ... }
public new void UnSelect(int row){ ... }
public new bool IsSelected(int row){ ... }
protected new void ResetSelection(){ ... }
It works, but not always - it's necessary to find another methods/properties to override I think.
You may create your own event OnSelection etc. in these methods (or create your own delegate with another parameters):
public event EventHandler OnSelection;
and use it:
if(OnSelection!=null) OnSelection(this);
0
At this point I have this problem: How can I get the data object behind the currently selected row of a DataGrid WinControl.
How can I retrive the value of a specific field what corespond to that selected row - for example
value for IDField who does'nt have a reprezentative column in that DataGrid.
A C# example will be good!
0
CurrentCellChanged
CurrentCell.RowNumber