Results 1 to 2 of 2

Thread: Datagrid and Button

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2002
    Posts
    31

    Datagrid and Button

    Hello there

    Can someone tell med how to link a combo box to cell in a datagrid. (Datagrid.Columns.Add(4).Button = True)


    Best regards
    Pet

  2. #2
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Well

    You mention button, the combobox...

    Anyways, this uses a FlexGrid not DataGrid, but the theory's about the same...

    VB Code:
    1. 'cboCell is the name of the combo box and msfCarlines is the name of the MSFlexGrid
    2.  
    3. 'Put SetUpCombo In the Grids Click Event
    4. Dim i As Integer
    5.  
    6.     ' Prepare combo
    7.     With cboCell
    8.         ' Hide combo
    9.         .Visible = False
    10.         .AddItem "line 1"
    11.         .AddItem "line 2"
    12.         .AddItem "line 3"
    13.     End With
    14.    
    15.     ' Prepare grid
    16.     With msfCarlines
    17.         .Top = 0
    18.         .Width = Me.Width
    19.         .Height = Me.Height
    20.         .Left = 0
    21.         For i = 0 To msfCarlines.Cols - 1
    22.             .RowHeight(i) = cboCell.Height
    23.         Next i
    24.     End With
    25.  
    26.  
    27. Private Sub SetupCombo()
    28. ' Setup the combobox by positioning and sizing it over the
    29. ' current flexgrid cell
    30.  
    31. Dim sngL As Single
    32. Dim sngT As Single
    33. Dim sngW As Single
    34. Dim sngH As Single
    35.  
    36.     With msfCarlines.Container
    37.         sngL = .ScaleX(msfCarlines.CellLeft, vbTwips, .ScaleMode)
    38.         sngT = .ScaleY(msfCarlines.CellTop, vbTwips, .ScaleMode)
    39.         sngW = .ScaleX(msfCarlines.CellWidth, vbTwips, .ScaleMode)
    40.         sngH = .ScaleY(msfCarlines.CellHeight, vbTwips, .ScaleMode)
    41.     End With
    42.  
    43.     With cboCell
    44.         .Move msfCarlines.Left + sngL, msfCarlines.Top + sngT, sngW
    45.         .Visible = True
    46.         .SetFocus
    47.     End With
    48.  
    49. End Sub
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

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