Solved

DBGrid Control

Posted on 1997-11-19
9
608 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
 
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

706 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

20 Experts available now in Live!

Get 1:1 Help Now