Solved

Populate list Items in DBGRID list

Posted on 2001-06-26
3
149 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
Comment Utility
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
Comment Utility
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
Comment Utility
Comment from expert accepted as answer

Computer101
E-E Moderator
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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…
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…
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…
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…

772 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