views:

415

answers:

3

Hello, I am using datagridview and its datasource is a BindingList. But when I try to change the visibility of first row, I am getting InvalidOperationException. How can I change first row's visible value?

Thanks in advance.

A: 

Apply a filter perhaps on the DataSource or the grid.

leppie
A: 

On prerender, in the web domain, set the visible property.

In windows domain, make sure it is not the header row type. You can't hide that, AFAIK. Otherwise just hide it within the ondatabind.

Jeff Meatball Yang
Hello,I could not find any property about row type.Can you please provide sample source code?I am developing a windows desktop application.many thanks
AFgone
+2  A: 

I found how to do it.

You must specify:

datagridview.CurrentCell = null;

before setting:

row.Visible = false;

because if currentCell is in the row which is wanted to be hide, then mentioned problem occurs.

regards

AFgone
Of course. It's such an obvious thing in hind sight and one I've had trouble with too. Good work.
GenericMeatUnit