Filling a combobox from MTGC with data from a datatable

R

reidarT

I have found a good combobox with multiple fields
The example shows filling the combobox from a listview, but I want to fill
it with zip-code and cities from a database.
The example is as follows:
Dim dtLoading As New DataTable("UsStates")

dtLoading.Columns.Add("Name", System.Type.GetType("System.String"))

dtLoading.Columns.Add("Abbreviation", System.Type.GetType("System.String"))

dtLoading.Columns.Add("Population", System.Type.GetType("System.String"))

dtLoading.Columns.Add("Size", System.Type.GetType("System.String"))

For Each li As ListViewItem In lsvData.Items

Dim dr As DataRow

dr = dtLoading.NewRow

dr("Name") = li.Text

dr("Abbreviation") = li.SubItems(1).Text

dr("Population") = li.SubItems(2).Text

dr("Size") = li.SubItems(3).Text

dtLoading.Rows.Add(dr)

Next

comboTest.SelectedIndex = -1

comboTest.Items.Clear()

comboTest.LoadingType = MTGCComboBox.CaricamentoCombo.DataTable

comboTest.SourceDataString = New String(3) {"Name", "Abbreviation",
"Population", "Size"}

comboTest.SourceDataTable = dtLoading

MsgBox("Loading completed!", MsgBoxStyle.Information)

How can I make the source a datatable instead of the listview

regards

reidarT
 
C

Cor Ligthert

Reidar,

The combobox is filled from a datatable (part of a dataset)
comboTest.SelectedIndex = -1
comboTest.Items.Clear()
comboTest.LoadingType = MTGCComboBox.CaricamentoCombo.DataTable
comboTest.SourceDataString = New String(3) {"Name", "Abbreviation",
"Population", "Size"}
comboTest.SourceDataTable = dtLoading
MsgBox("Loading completed!", MsgBoxStyle.Information)

Probably it is
comboTest.LoadingType = mydataset.tables(0)

Can you give us the link to this combo?

Cor
 
C

Cor Ligthert

Reidar,

Looks nice I think that Pieter will be fond of this one. Do you have it
running now?

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top