0

So for one of my Windows Forms, I am using DataGridView control. I need to hide or remove some rows, because I want to show only the first 5 rows with the biggest result in the 3rd column.

I load my data from BinaryReader (DAT file). DataGridView shows my recorded data, but it loads all rows. I need only 5 rows.

DataGridView1.Row[].Visible = False

I tried with this one, but i got IndexOfOutRange exception. Any other solution ? Thanks in advance!

Stoyan377
  • 11
  • 4
  • Index starts with 0. Have you tried with correct number? – Alex Dec 22 '15 at 08:59
  • Possible duplicate of [Unable To set row visible false of a datagridview](http://stackoverflow.com/questions/18942017/unable-to-set-row-visible-false-of-a-datagridview) – Alex Dec 22 '15 at 09:00
  • Show the full code!! `DataGridView1.Row[]` is obviously missing the index and would not even compile..! – TaW Dec 22 '15 at 09:49
  • Have a look at this page to include code so that users can duplicate your problem and find a solotion [mcve] – David Wilson Dec 22 '15 at 13:14

2 Answers2

0

I think it may be the problem because your current selected cell can not be hidden. Try this:

DataGridView1.CurrentCell = null;
DataGridView1.Row[i].Visible = False
Denis Duh
  • 11
  • 3
0

Find Row in DataGrid_RowBoundEvent

then row visible false

Deepak
  • 121
  • 5