Hi,
[quoted text, click to view] "George Hardy" <spamlessihope-ghardy@usmedequip.com> wrote in message
news:uyBIxm9BGHA.1028@TK2MSFTNGP11.phx.gbl...
> it must be just me, it seems a little overly-complicated to get the
> CurrentRowIndex for what is actually being shown in the grid.
It's commonly done this way, because a CurrencyManager (which you get from
BindingContext) manages list bindings and therefore have some interesting
properties (regardless of what Control is bound), the code i already showed
you is really a shortcut for :
// because DataGrid.DataMember changes, you'll get
// the right CurrencyManager for the list that's showing
CurrencyManager cm = (CurrencyManager)
BindingContext[dataGrid1.DataSource, dataGrid1.DataMember];
// get position
int position = cm.Position;
// get the list that the DataGrid visually represents which is not
// always the same as the DataSource, but it's always a
// DataView (unless you bound to a custom collection):
DataView dv = (DataView)cm.List;
// get current item:
DataRowView currentDRV = dv[position];
HTH,
Greetings
[quoted text, click to view] >
> i did see the datamamber change, thanks...now i can evaluate that if the
> user double-clicks on the grid, so i wont get any more "index out of
> bounds" crap (from the falsly reported currentrowindex).
>
> gh
>
>
> "Bart Mermuys" <bmermuys.nospam@hotmail.com> wrote in message
> news:%23u6xpx7BGHA.344@TK2MSFTNGP11.phx.gbl...
>> Hi,
>>
>> "George Hardy" <spamlessihope-ghardy@usmedequip.com> wrote in message
>> news:O3fCt20BGHA.3876@tk2msftngp13.phx.gbl...
>>> Hi all,
>>>
>>> I have parent/child datagrid (showing transactions and transaction
>>> details when the (+) sign is clicked on the grid.
>>>
>>> There is a method to "expand" the row, and an event to fire when you
>>> click "back to parent record", but i see nothing (no property or event)
>>> in this stupid grid to tell me if someone has "expanded" the grid. So,
>>> when the user double-clicks on the row to open the detail form, it has
>>> no idea what row is actually clicked, because the currentrowindex
>>> property is still thinking that it is in parent mode.
>>
>> When you bind a DataGrid to a DataTable or DataSet it's internally bound
>> to a DataView, you can get the current DataRowView from whatever DataView
>> is currently showing :
>>
>> DataRowView currentDRV = (DataRowView)
>> BindingContext[dataGrid1.DataSource, dataGrid1.DataMember].Current;
>>
>> // ... read fields from currentDRV ...
>>
>> Notice, that dataGrid1.DataMember changes when you navigate to a child
>> view or back to a parent view.
>>
>> HTH,
>> Greetings
>>
>>
>>>
>>> is there a work-around for this, or did i completely miss something?
>>>
>>> thanks in advance!
>>>
>>> george hardy
>>>
>>
>>
>
>