Solved

Populate list Items in DBGRID list

Posted on 2001-06-26
3
150 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

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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 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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

929 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

11 Experts available now in Live!

Get 1:1 Help Now