Show various datagridview columns based on certain criteria RRS feed

  • Question

  • Hi all,

    I've got a datagridview that returns a bunch of columns.  However, if certain criteria are met, I only want to show specific columns and also change the headertext in them.

    For example:
    Let's say I have 5 columns (columns a through e) that are normally returned in my datagridview.

    If criteria x is met, I only want to show columns a, b and d and I want to have the headertext of column b and d change from b and d to 2 and 4, respectively.

    How do I go about doing that?
    Tuesday, September 25, 2007 10:06 PM


  • Nevermind, I figured it out.

    Me.DataGridView1.Columns(index).Visible = False
    Me.DataGridView1.Columns(index).HeaderText = "new text"
    Tuesday, September 25, 2007 10:23 PM