Solved

Populate list Items in DBGRID list

Posted on 2001-06-26
3
154 Views
Last Modified: 2010-05-02
I have inserted a button in a column of a grid

dbgrid1.columns(1).button=true
Now the button is displayed
Can anybody give me a sample code for the Button_click event for this?
Thank you!
Thakurdesai
0
Comment
Question by:thakurdesai
3 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 50 total points
ID: 6230341
This example is used to make a datacombo appear in the cell when the button is clicked. You can use any other control in this situation, a list box or combo or whatever.

Private Sub DBGrid1_ButtonClick(ByVal ColIndex As Integer)
' Assign the Column object to Co because it will be used
  ' more than once.
  Dim Co As Column
   
  Set Co = DBGrid1.Columns(ColIndex)
   
  ' Position and drop down list1 at the right edge of the
  ' current cell.
  DataCombo1.Left = DBGrid1.Left + Co.Left + Co.Width
  DataCombo1.Top = DBGrid1.Top + DBGrid1.RowTop(DataGrid1.Row)
  DataCombo1.Visible = True
  DataCombo1.ZOrder 0
  DataCombo1.SetFocus
End Sub

Private Sub DBGrid1_Scroll(Cancel As Integer)
' Hide the list if we scroll.
  DataCombo1.Visible = False
End Sub

Private Sub List1_Click()
  'Update the appropriate field in the record.
  DataCombo1.Visible = False
End Sub

When the button is clicked, the data combo is displayed next to the field. Choosing an item
from the list will then update the record (you need to put in the appropriate code for this) and hide the datacombo
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7139843
Hi thakurdesai@devx,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will suggest to:

    Accept TimCottee's comment(s) as an answer.

thakurdesai@devx, if you think your question was not answered at all or if you need help, you can simply post a new comment here.  Community Support moderators will follow up.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 
LVL 1

Expert Comment

by:Computer101
ID: 7178875
Comment from expert accepted as answer

Computer101
E-E Moderator
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

679 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