Solved

VB grid capabilities

Posted on 2004-04-20
3
682 Views
Last Modified: 2012-06-27
Hello,

I want to use a grid in VB6 that is capable of being bound to an ADO data source, and also is capable of hosting comboxes and other controls in the grid columns. Do the native Datagrid and Hierarchical FlexGrid in VB6 do this? As far as I can see, all the grids that come with VB are incapable of "hosting" other controls. Any comments or recommendations?

Thanks,
Trimtrom
0
Comment
Question by:trimtrom
  • 2
3 Comments
 
LVL 19

Expert Comment

by:Shauli
ID: 10871941
Datagrid has a built in "button", which can be defined for each cell. If you want a combobox effect you need to place a listbox below the cell. As per the FlexGrid. It does not have built in controls. However, what we do is, again, place textboxes or combobox on the given cell.

S
0
 
LVL 19

Accepted Solution

by:
Shauli earned 100 total points
ID: 10872175
This would be an example how to place a combobox over  MSFlexGrid:

Locate MSFlexGrid & a combobox on your form, and copy this code:

'=============on form level
Private Sub Form_Load()
MSFlexGrid1.ScrollBars = flexScrollBarVertical
Combo1.Visible = False
End Sub

Private Sub Form_Resize()
MSFlexGrid1.Width = Me.ScaleWidth
MSFlexGrid1.Rows = 8
MSFlexGrid1.Height = Combo1.Height * 8
MSFlexGrid1.Left = 240
MSFlexGrid1.Top = 240
MSFlexGrid1.RowHeightMin = Combo1.Height
MSFlexGrid1.Cols = 5
Dim c
For c = 0 To 4
    MSFlexGrid1.ColWidth(c) = (Me.ScaleWidth - 240) / 5
Next c
End Sub

Private Sub MSFlexGrid1_LostFocus()
Combo1.Visible = False
End Sub

Private Sub MSFlexGrid1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Combo1.Visible = False
        Combo1.Left = MSFlexGrid1.Left + MSFlexGrid1.CellLeft
        Combo1.Top = MSFlexGrid1.Top + MSFlexGrid1.CellTop
        Combo1.Width = MSFlexGrid1.CellWidth
        Combo1.Visible = True
End Sub

S
0
 

Author Comment

by:trimtrom
ID: 10872362
Hi,

That is certainly very interesting code you've got there.  I never thought this was possible.  I'll have to experiment!

Thanks,
Trimtrom
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Windows 10 start screen issues 9 51
Determine Range to Select 5 42
Cannot Load VB6 on Windows 10. Installed OK but error on opening existing project. 7 76
Hide vba in gp 7 83
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now