Solved

VB grid capabilities

Posted on 2004-04-20
3
683 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Macro which automatically sends attachment to Outlook 14 70
Hide vba in gp 7 95
Add and format columns in vb6 7 57
Prevent user closing word document opened with VB6 6 74
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

809 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