views:

542

answers:

2

I've made a custom DataGridViewCell that displays a custom control instead of the cell; but if the DataGridView uses shared rows, then the custom control instance is also shared, so you get strange behaviour (for example, hovering over buttons highlights all the buttons). Also, I can't access the DataGridViewCell.Selected property, so I don't know what colour to paint the row.

How do I prevent a DataGridView from sharing rows? I know I can add the rows using the Rows.Add(object[]) override, but then the first row is still shared (i.e. has index -1) so the problem with colours still applies.

I need to be able to tell the DataGridView not to share a row containing a custom cell. Can that be done with attributes? Can it be done at all?

+1  A: 

Try to set a Tooltip Text in one cell of the Row

A row cannot be shared in any of the following situations: The row contains a single selected cell that is not in a selected column. The row contains a cell with its ToolTipText or ContextMenuStrip properties set. The row contains a DataGridViewComboBoxCell with its Items property set.

or read

http://msdn.microsoft.com/en-us/library/ha5xt0d9.aspx

for more Information

Georg
It's a bit hacky, but it'll do. Thanks!
Simon
A: 
DataGridViewRowCollection.AddRange(params DataGridViewRow[] dataGridViewRows)

with

new[]{someDataGridviewRow}

worked for me.

Ptr