Thanks. I tried :
int ThisRec;
ThisRec =
(int)dataSet11.Tables["SpClientsByCompany"].Rows[dataGrid1.CurrentRowIndex][
o];
which seems to work OK but what if the grid is sorted? Is there not some
sort of cursor that moves through the dataset as the user moves through the
gird? As the grid knows how to edit data it must be tracking where it is in
relation to the dataset? Is that what a currency manager does?
I found a web page that says: The CurrencyManager object monitors the
position and otherwise supervises bindings to that data source.
If this is the case then is seems that
cm =
(CurrencyManager)this.BindingContex[dataSet11.Tables["SpClientsByCompany"]];
int This Rec
ThisRec = (int)dataSet11.Tables['SpClientsByCompany'].Rows[cm.Position][0];
should work even is the grid is sorted but it always returns the same value.
It seems like displaying two forms with related data is something every real
world database program must do so I am surprised that I cannot find and
example of it anywhere.
"William Ryan eMVP" <do********@comcast.nospam.net> wrote in message
news:eI**************@TK2MSFTNGP10.phx.gbl...
CurrencyManagers aren't complicated and exist whether you want them or
not ;-). However, you don't need to specifically address it.
If the order of the underlying table matches the grid (ie it hasn't been
sorted) you can use
DataRow dr;
dr = dataSetName.Tables["Whatever"].Rows[DataGrid.CurrentRowIndex];
you can reference a specific value in a column by adding a reference
Rows[0][1] for instance. (Although you need to do a cast to wahtever type
the value is).
Youy can also use DataGrid[0,1] or use the CurrentRowIndex
/CurrentColumnIndex to get that info.
There's another property of the Grid, IsSelected that will indicate if the
row is Selected or not that may help you in this endeavor.
HTH,
Bill
www.devbuzz.com
www.knowdotnet.com
"Red Green" <re*@green.com> wrote in message
news:OG**************@TK2MSFTNGP11.phx.gbl... I have a form with a datagrid and a dataset bound to it. I want to
launch a second form and pass it a value from whichever record the user has selected. I can't find an example anywhere that shows me how to do this. I know
how to launch the 2nd form and how to make a public variable to hold the value
but I can't figure out how to get the value.
In Delphi what I need should be something like
dataSet1.FieldByName('UserID').Value;
Is there an easy way to get this in .NET? Do I need a currency manager
or something complicated like that?