Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable To set row visible false of a datagridview

I have a DataGridView where I set DataSource:

taskerEntities te = new taskerEntities(); var OMsMasterDescriptiveIndicators = te.MyTable.Select(x => new lccls {Id = x.Id, name = x.name }).ToList(); MyGrid.DataSource = OMsMasterDescriptiveIndicators; 

with my class lccls as

public class lccls     {         public string Id { get; set; }         public Nullable<decimal> name { get; set; }     } 

At a certain event I want to make the current row invisible:

 MyGrid.Rows[5].Visible = false; 

But I am unable to do this. Instead an exception is thrown with the following error message:

Row associated with the currency manager's position cannot be made invisible

I suspect the reason is related to setting DataSource, but why?

like image 605
Amit Bisht Avatar asked Sep 22 '13 08:09

Amit Bisht


Video Answer


1 Answers

After searching a lot, I got the solution

CurrencyManager currencyManager1 = (CurrencyManager)BindingContext[MyGrid.DataSource];   currencyManager1.SuspendBinding(); MyGrid.Rows[5].Visible = false; currencyManager1.ResumeBinding(); 
like image 152
Amit Bisht Avatar answered Oct 04 '22 00:10

Amit Bisht