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?
I have an example for U. I have a datagridview that may multiselected row. When i click the button to visible false row that selected. Try this:
Remember to set property SelectionMode: FullRowSelect
Example
this show only the row that have in the cell index 14, if this is blank or empty the whole row not show
Cannot set yourDataGridView row visible property to false when current row index Will encounter such error if trying to hide current cell
soulution :
when yourDataGridView Data source is not null :
when yourDataGridView Data source is null :
After searching a lot, I got the solution