Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Combos in Grids
Message
 
To
07/11/2000 11:40:14
Peter Walburn
Omega Data Services Ltd
Aberdeen, United Kingdom
General information
Forum:
Visual Basic
Category:
Other
Title:
Miscellaneous
Thread ID:
00438822
Message ID:
00438953
Views:
10
>Hello,
>
>I am currently having to write some VB applications and in a lot of forms, there are to be grids to display data. In the tables underlying the grids, the stored value is a shorter value than that displayed on the grid (for example it may store a number, but display a text string).
>
>It seems that in VB there is not a grid that does this. Am I missing something or am I going to have to buy a third party grid control? Is this something that will be fixed in the next version of Visual Studio (as I know there is a decent grid control for VFP)?
>
>Pete

Try this:
Add a ListBox and make its visible property to False. 


'Add this code to the form declaration 

Option Explicit 
Dim intColIdx As Integer 
 'This will contain the index for the current  cell in the dbgrid 
Dim blnListShow As Boolean 'is the list showing or not 


Private Sub DBGrid1_ButtonClick(ByVal ColIndex As Integer) 
Dim intTop As Integer 
intColIdx = ColIndex 
If blnListShow = False Then 'if the list is not showing then... 
blnListShow = True 
List1.Left = DBGrid1.Columns(ColIndex).Left + 360 
intTop = DBGrid1.Top + (DBGrid1.RowHeight * (DBGrid1.Row +2)) 
 List1.Top = intTop 
 List1.Width = DBGrid1.Columns(ColIndex).Width + 15 
                     List1.Visible = True 
                  List1.SetFocus 
Else 'if the list is show, hide it 
             blnListShow = False 
              List1.Visible = False 
End If 
End Sub 


          Private Sub Form_Load() 
                blnListShow = False 'initialize 
           End Sub 

        Private Sub List1_Click() 
DBGrid1.Columns(intColIdx).Text = List1.Text 
 'set the value of the dbgrid 
  List1.Visible = False 'hide the list 
        End Sub 

                      Private Sub List1_LostFocus() 
                          blnListShow = False 
                          List1.Visible = False 
                      End Sub 
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform