We help IT Professionals succeed at work.

Add fields to combo box

priswong
priswong asked
on
how to add fields to a combo box in a TDBGrid column from an access database table?
Comment
Watch Question

Commented:
Using ValueItems Collection we can add values to the combo box in TrueDB Grid.

example write the following code wherever is required.
this example chenges column 0 to a combobox presentation and displays Male and Female as list items.

replace displayvalue and value with your recordset field values coming from Access DB.



    Dim ValITEM1 As New ValueItem
   
    With TDBGrid1.Columns(0)
       
        .ValueItems.Clear
        .ValueItems.Presentation = dbgComboBox
        .ValueItems.Validate = True
        .ValueItems.CycleOnClick = True
       
        ValITEM1.DisplayValue = "M: Male"
        ValITEM1.Value = "M"
        .ValueItems.Add ValITEM1
       
        ValITEM1.DisplayValue = "F: FeMale"
        ValITEM1.Value = "F"
        .ValueItems.Add ValITEM1
       
       
    End With

hope this helps you.

to add fields to combo box in a grid you can use an adodb control.from that give the data source name of adodb to combo box. first add ado data control to your form from project--> components.then set the properties of that control.in that map you table fields to that control.by using this control your are fetching the data at a time.now add this control to you combo box datasource and field you are refering to datafield.