pb with .selectedvalue of a combobox

  • Thread starter Thread starter Sam
  • Start date Start date
S

Sam

Hi,

In this code my combobox is properly filled with all the records in my
dataset. But when I want to set it to a value using selectedvalue, it
just don't work as cboViewTable.SelectedValue will always be equal to
Nothing, although ds.Tables(0).Rows(m_curRow).Item("ViewTable") is
equal to "string1"
What's wrong with this code ?


with cboViewTable
.DataSource = m_frmFields.Control.Tables(3)
.DisplayMember = "table_name"
.ValueMember = "table_name"
End With

cboViewTable.SelectedValue =
ds.Tables(0).Rows(m_curRow).Item("ViewTable")

Thx
 
Actually I got a weird problem in the same kind. Below if i select a
value in my first combo, it will also set the second combo to the same
value. I know they have the same datsource, but they should be
independent ! What's wrong there?

With cboViewTable
.DataSource = m_frmFields.Control.Tables(3)
.DisplayMember = "table_name"
.ValueMember = "table_name"
End With

With cboInsertTable
.DataSource = m_frmFields.Control.Tables(3)
.DisplayMember = "table_name"
.ValueMember = "table_name"
End With
 
Actually I believe since they have the same datasource so they point to
the same memory location. That's why when I modify one, the other one
is modified too. But how can i assign them the same datasource then ?
Like I would for the different column of a datagrid....
 
Sam,

It are two different problems.
Use for the cboViewTable. the selected index that you find with
cboViewTable.FindString or FindStringExact.

To let more controls go not synchonize you have to use seperated dataviews
from the same table as a datasource..

I hope this helps,

Cor
 
I've made a copy of my datatable insead, using Copy. It works, if this
correct ?

I don't understand your first sentence, sorry

thx
 
Sam,

Use a dataview as datasource not a copy of your datatable.

dim dv1 as new Dataview(mydatatable)
dim dv2 as new Dataview(mydatatable)

Combo1.datasource = dv1
Combo2.datasource = dv2

Cor
 
Sam

cmb.selectedindex = cmb.findstringexact("myname")

This is as well the way to make such an autokey combobox.

I hope this helps,

Cor
 
Back
Top