datagrid parentrow or childrow

M

Marjolein Hubrecht

Hi

How do I determine on the currentcellchanged event of my datagrid if the
currentcell is in a parent row or in a child row?

Thanks

Marjolein
 
P

Pete Wright

You need to use the currency manager. This will let you get at the actual
row that's current and from that row you will be able to determine which
table you are in, whether there are child or parent rows etc etc.
CurrencyManager cm = (CurrencyManager) dataGrid1.BindingContext[myDataSet];

DataRowView row = (DataRowView) cm.Current;

Hope that helps,

--
 
M

Marjolein Hubrecht

The cm.current stays the same if I click a parent or a child row in my
datagrid.
My datasource is a custom collection that implements IBindingList.
So my cm.current contains a parent object with a collection of child
objects.

My grid contains two tablestyles, should I maybe look in that direction?

Thanks

marjolein


Pete Wright said:
You need to use the currency manager. This will let you get at the actual
row that's current and from that row you will be able to determine which
table you are in, whether there are child or parent rows etc etc.
CurrencyManager cm = (CurrencyManager) dataGrid1.BindingContext[myDataSet];

DataRowView row = (DataRowView) cm.Current;

Hope that helps,

--
--------------------------------------------------------
Peter Wright (www.petewright.org)
Author of ADO.NET Novice To Pro
From Apress. www.apress.com (and 10
other doorstops from Wrox)


Marjolein Hubrecht said:
Hi

How do I determine on the currentcellchanged event of my datagrid if the
currentcell is in a parent row or in a child row?

Thanks

Marjolein
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top