Data confusion - Selecting data in one DataGridView based on selection in another

Posted by Logan Young on Stack Overflow See other posts from Stack Overflow or by Logan Young
Published on 2009-10-05T08:54:18Z Indexed on 2010/04/30 4:07 UTC
Read the original article Hit count: 161

Filed under:
|
|

This probably isn't the best way to do what I want, but I can't think of anything else to try...

NB: I'm using Visual Basic.NET

My form has 2 DataGridView controls. One of these is bound to a DataSet, the other isn't visible - at least not until the user selects a uniqueidentifier cell in the 1st grid.

When the user makes this selection, the 2nd grid will become visible and display the row from another with the same id as the one selected in the 1st grid.

So, basically, I want to dynamically display data in one grid based on user selection in another grid.

My code looks like this so far...

Private Sub RulesGrid_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles RulesGrid.CellClick
    Try
        FlagsGrid.Visible = True
        ''// MsgBox(RulesGrid.CurrentCell.Value.ToString())
        Dim sql As String = "SELECT * FROM ctblMKA_Status_Flags " + _
            "WHERE intStatusID = '" & RulesGrid.CurrentCell.Value & "'"
        DSFlags = GetDS(sql)
        DSFlags.DataSetName = "FlagsDataSet"
        FlagsGrid.DataSource = DSFlags
        ProgressBar.Visible = False
    Catch ex As Exception
        MsgBox(ex.ToString)
    End Try
End Sub

I feel like I'm missing something here... Any ideas anyone?

© Stack Overflow or respective owner

Related posts about datagridview

Related posts about winforms