none
how to hide row base on the specific value RRS feed

  • Question

  • hello?

    i have a table:

    +--------------+--------------+------+-----+----------------+
    | image          | Item           | Price | qty  | Availability     |
    +--------------+--------------+------+-----+----------------+
    |Image1.jpeg | laptop         | 2000  |6     | Available        |
    |Image1.jpeg | cellphone    | 1000  |5     | Unavailable     |
    |Image1.jpeg |ipad             | 500   |7     | Unavailable     |
    +--------------+--------------+------+-----+----------------+

    this table already showed in datagridview. Now I want to hide all the rows that contains " Unavailable "

    i used this code:

     For i As Integer = 0 To BunifuCustomDataGrid1.Rows.Count - 1
       
                If BunifuCustomDataGrid1.Rows(i).Cells("Availability").Value = "Unavailable" Then
                    BunifuCustomDataGrid1.Rows(i).Visible = False
    
    
                End If
            Next

    but it says:

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

    how can i solve this problem? can anyone please help me? Thank you!

    Sunday, September 16, 2018 10:04 AM

Answers

  • Hello,

    Somewhere you have assigned DataSource property of DataGridView.

    Most Likely there is DataTable or DataView.

    On DataTable.DefaultView or your DataView you can set RowFilter:

    dt.DefaultView.RowFilter = "Availability = 'Unavailable'";
    grid.DataSource = dt.DefaultView;


    Sincerely, Highly skilled coding monkey.

    • Marked as answer by euchan09 Sunday, September 16, 2018 10:43 AM
    Sunday, September 16, 2018 10:38 AM