Who is online? 187 guests and 0 members
Member login | Become a member
posted 4/1/2009 3:03:21 AM by vivek_iit
In your windows forms applicatons, if you want to hide/make inivisible a row of the DataGridView control at runtime, you would assume that this line will do the trick:
for (int i = 0; i < dgridView.Rows.Count; i++) { if(someCondition) dgridView.Rows[i].Visible = false; }
But the moment you do this, you will get this error:Row associated with the currency manager's position cannot be made invisible
The reason for this particular error is that you cannot make modifications to a row at runtime which is bound to datasource, unless you suspned the binding on all rows using CurrencyManager object like:
cManager.SuspendBinding();dgridView.Rows[i].Visible = false;
Or, you can also do this:
dgridView.CurrentCell = null;dgridView.Rows[i].Visible = false;
Here we are setting the current cell to null and then hiding the row.
Note: if you are using sorting, then you would need to hide the hidden rows again because after sorting hidden rows would show up again unless you remove them from the binding source itself.
vivek_iit (Member since: 11/27/2008 11:54:25 AM) I am one of the administrators at CodeAsp.Net and I love programming, architecting solutions, code reviews, teaching and writing about ASP.NET.
View vivek_iit 's profile
Leave a comment
It's fast, easy and free! Submit articles, get your own blog, ask questions & give answers in the forums, and become a better developer, faster.
enter your email address: