All,
Am binding a dataset to a combobox control at form load,
Code :
Private sub form1_Load()
----
---
Try
objClientDataAdaptor.Fill(objDataSet, "Client_Name")
cboClient.DataSource = objDataSet.Tables("Client_Name")
cboClient.DisplayMember = "Client_ID"
cboClient.SelectedIndex = -1
Messagebox.show(cboClient.selectedindex) ' returns -1 as it should!
Catch ae As OleDbException
MessageBox.Show(ae.Message)
End Try
----
---
end sub
Though I am setting the selectedindex property to -1 , I am getting the first item displayed in combo box on form load.
I referred the below link that reports the BUG
http://support.microsoft.com/default.aspx?scid=kb;en-us;327244
I tried the method suggested to ,
1) execute
cboClient.selectedindex = -1
cboClient.selectedindex = -1
2) execute
cboClient.selectedindex = 0
cboClient.selectedindex = -1
None of which seem to work.
Subsequently I came across this link that explains the problems when doing a data binding with a dataset to a combo box,
http://www.windowsitpro.com/Windows/Article/ArticleID/41825/41825.html
I tried their suggested method to use a boolean m_bLoading variable to modify the firing of SelectedValueChanged event when the data values are first loaded into the control. and set the Selected index property to -1.
All with no success.
PROBLEM : Anyone can suggest me the method to CLEAR the combo box of the first item and display nothing on load.
Thnx
Odyzeus
Am binding a dataset to a combobox control at form load,
Code :
Private sub form1_Load()
----
---
Try
objClientDataAdaptor.Fill(objDataSet, "Client_Name")
cboClient.DataSource = objDataSet.Tables("Client_Name")
cboClient.DisplayMember = "Client_ID"
cboClient.SelectedIndex = -1
Messagebox.show(cboClient.selectedindex) ' returns -1 as it should!
Catch ae As OleDbException
MessageBox.Show(ae.Message)
End Try
----
---
end sub
Though I am setting the selectedindex property to -1 , I am getting the first item displayed in combo box on form load.
I referred the below link that reports the BUG
http://support.microsoft.com/default.aspx?scid=kb;en-us;327244
I tried the method suggested to ,
1) execute
cboClient.selectedindex = -1
cboClient.selectedindex = -1
2) execute
cboClient.selectedindex = 0
cboClient.selectedindex = -1
None of which seem to work.
Subsequently I came across this link that explains the problems when doing a data binding with a dataset to a combo box,
http://www.windowsitpro.com/Windows/Article/ArticleID/41825/41825.html
I tried their suggested method to use a boolean m_bLoading variable to modify the firing of SelectedValueChanged event when the data values are first loaded into the control. and set the Selected index property to -1.
All with no success.
PROBLEM : Anyone can suggest me the method to CLEAR the combo box of the first item and display nothing on load.
Thnx
Odyzeus