Results 1 to 3 of 3

Thread: [RESOLVED] populating drop down list of a datagrid column

Hybrid View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Posts
    403

    Resolved [RESOLVED] populating drop down list of a datagrid column

    is this possible?

    i have a datagrid with 2 columns... lets say col1 and col2.. in col2, i have a drop down button which is supposed to list all valid values for it. sorta like list of values.

    any ideas?

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: populating drop down list of a datagrid column

    You must supply another control that contains the list of values. When the button is clicked move the control into position, make it visible and give it focus. When the user selects a value, write the value to the grid cell, hide the control and put focus back onto the grid control.

    This sample code uses a ListBox placed just below the current cell.

    Code:
    Private Sub DataGrid1_ButtonClick(ByVal ColIndex As Integer)
        Dim lngLeft As Long
        Dim lngTop As Long
    
        lngLeft = DataGrid1.Left + DataGrid1.Columns(ColIndex).Left
        lngTop = DataGrid1.Top + DataGrid1.RowTop(DataGrid1.Row) + DataGrid1.RowHeight
        
        List1.Move lngLeft, lngTop, DataGrid1.Columns(ColIndex).Width
        List1.Visible = True
        List1.SetFocus
    End Sub
    
    Private Sub List1_Click()
        DataGrid1.Columns(2).Text = List1.Text
        List1.Visible = False
        DataGrid1.SetFocus
    End Sub

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Posts
    403

    Re: populating drop down list of a datagrid column

    thanks... this seems to work.. just hope it is as easy as in vb.net because i've decided to use vb.net instead of vb6 for my database application.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width