Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Dataset and Combobox position are different ?

0 views
Skip to first unread message

Luqman

unread,
Dec 5, 2002, 3:03:11 PM12/5/02
to
I have generated a dataset from OleDbDataAdapter (ActiveX) and I need to use
both of them through code, without setting the databinding properties of
text boxes and combo box.

The combo box is set at form_load with the following code.

'Form_Load()
With cboBroker
.DataSource=dsBroker
.DisplayMember="Name"
.ValueMember="Code"
End With

'Set the dataset position to 0
daBroker.Fill(dsBroker)

me.BindingContext(dsBroker).Position=0

txtCode.text=dsbroker.tables(0).Item(0)
txtName.text=dsbroker.tables(0).Item(1)

End Sub

Private Sub cboBroker_SelectedIndexChanged()

Me.BindingContext(dsbroker).Position=cboBroker.SelectedIndex
txtCode.text=dsbroker.tables(0).Item(0)
txtName.text=dsbroker.tables(0).Item(1)

End Sub

The Problem is that if I bind any one textbox with the dsBroker Dataset,
then it works fine otherwise changing the combobox at first time does not
change the position of dataset.

For example: When the form is loaded, it displays Code 1 and relative name
in combo box.

When I select the combo box and display the 2nd name in combo box, the Code
is still 1 instead of 2.

When I again select the combo box and display the 1st name, the Code now
shows 2 instead of 1.

If I delete the dsBroker ActiveX from form and create a new dataset in the
General Declaration form, everything works fine.

'General Declaration
Dim dsBroker as new Dataset

Any Idea why the position of combo box is not synchronizing with the
dataset in case of using Dataset ActiveX Control.

Best Regards,

Luqman

Russ Green

unread,
Dec 7, 2002, 7:36:18 AM12/7/02
to
i think im having a similar issue. see my post  ValueMember troubles in vb.net  in microsoft.public.dotnet.framework.windowsforms.controls
 
i'd love to sort this one out
 
Russ
 
 

Luqman

unread,
Dec 8, 2002, 3:11:35 AM12/8/02
to
Dear Russ,
 
If you bind even only one control on a form with the dataset activex control, by setting its databinding properties, then everything will work fine, otherwise without binding to any control, activex Control will not work properly. I think its a bug.
 
Best Regards,
 
Luqman
 
 
 

Russ Green

unread,
Dec 8, 2002, 8:16:56 AM12/8/02
to
I have to bind one of my combos to the data? Do you think it would be possible to make the bind in this funtion somehow?
 
Public Function PopulateListContol(ByVal ListControl As Object, ByVal ValMem As String, _
ByVal DisMem As String, ByVal Database As String, ByVal DataTable As String, ByRef ds As DataSet)
 
Try
'connection stuff
Dim da As New OleDb.OleDbDataAdapter("SELECT * FROM " & DataTable, _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Database)
 
da.Fill(ds)
 
ListControl.DataSource = ds.Tables(0)
ListControl.DisplayMember = DisMem
ListControl.ValueMember = ValMem
 
Catch ex As Exception
MsgBox(ex.Message)
End Try
 
End Function
 

Russ Green

unread,
Dec 11, 2002, 6:11:00 AM12/11/02
to
The combo Sort value was set to true. I t seems combos only sort the DisplayValue. I put ORDER BY in the sql clause.
 
Everything works now
0 new messages