Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

DBGrid Control

Posted on 1997-11-19
9
Medium Priority
?
627 Views
Last Modified: 2010-05-18
VB5 Gives the ability to provide a build-in combobox within a DBGrid control. I'ld like to use that function but there is very few information available about it. Is there someone who can help me with writing an example code ?
0
Comment
Question by:ndb
9 Comments
 
LVL 6

Expert Comment

by:anthonyc
ID: 1441470
What you need to do is create some "valueitems" for a column.  to do this, do the following:

dim viItem  as valueitem


With .Columns(0) 'works on the first column
            .Valueitems.presentation = dbgComboBox

            .ValueItems.Clear
            .ValueItems.CycleOnClick = True
            .ValueItems.Translate = True
            .ValueItems.Validate = True
           
            'add value items
            viItem.DisplayValue = "Value"
            viItem.Value = True
            .ValueItems.Add viItem
           
            viItem.DisplayValue = "Text"
            viItem.Value = False
            .ValueItems.Add viItem  'you can add as many as ya want
End With

0
 
LVL 6

Expert Comment

by:anthonyc
ID: 1441471
I forgot to put the dbgrid1 in the with statement.

The with statement should read

with dbgrid1.columns(0)


sorry about that
0
 
LVL 1

Author Comment

by:ndb
ID: 1441472
Can I link the valueitems to another table with data ?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 6

Expert Comment

by:anthonyc
ID: 1441473
well you can:

dim rsData as recordset
dim viItem as new valueitem

set rsData = db.openrecordset("select keyval, displayval from table1", dbOpenSnapshot)

with dbgrid1.columns(0)
   do until rsdata.eof
     viItem.value = rsData!keyval
     viItem.displayvalue = rsData!displayval
     .valueitems.add viItem
     rsData.movenext
   loop
end with


but it cant be done directly
   
0
 
LVL 1

Author Comment

by:ndb
ID: 1441474
What kind of DBGrid are you using. I don't find the property ValueItems.
0
 
LVL 1

Author Comment

by:ndb
ID: 1441475
I don't have these properties you are talking about.
0
 
LVL 3

Accepted Solution

by:
Matvey earned 300 total points
ID: 1441476
Actually I had the same problem.
My solution was to attach a ListBox to the event ButtonClick
of the DBGrid. But DBGrid's button is ugly, and you
shouldn't use it. You should put a ComboBox in the place
of the cell any time it gets focus.

Good luck !
                Matvey
0
 
LVL 1

Author Comment

by:ndb
ID: 1441477
It seems to be the only solution.
0
 

Expert Comment

by:NAVemail
ID: 23099927
I tried the solution and it does not work for me.
I have the TDBGrid and I wanted to make a column from text to comboBox.
The column it shows the combobox control but the items are not displayed when I click on the arrow.
This is my code:
            With grd.Columns(12)  'works on the first column
                .ValueItems.Presentation = dbgComboBox

                .ValueItems.Clear
                .ValueItems.CycleOnClick = True
                .ValueItems.Translate = True
                .ValueItems.Validate = True
           
                'add value items
                viItem.DisplayValue = "05 - Reason 91"
                viItem.Value = True
                .ValueItems.Add viItem
           
                viItem.DisplayValue = "07 - Reason 48"
                viItem.Value = True
                .ValueItems.Add viItem
               
                viItem.DisplayValue = "09 - Reason 8"
                viItem.Value = True
                .ValueItems.Add viItem
           
                viItem.DisplayValue = "08 - Reason 24"
                viItem.Value = True
                .ValueItems.Add viItem
            End With
Non of the option are shown.

could someone help me please?

Thank you
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
Suggested Courses

916 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