473,386 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Clear Combobox Items

Below is my code for a combobox. Basically, I have 2 comboboxes. 1
box is the application selection and the other retrieves data from the
dataset (SQL Server) to populate the drop down in the otehr box. I
want to make a selection in the app combobox, update the second box
and when I select a new app, it should remove all items in teh 2nd
combobox and refresh the list with only the selected app. With this
code it appears the binding is not occurring properly after I detach
it. I have tried Remove, RemoveAt and Items.Clear() and nothing seems
to work. Currently, I receive the message in my 2nd combo box that
says, "System.Data.DataViewManagerListItemTypeDescriptor ".

Please help me! It can't be this difficult to drop a datasource,
clear items, bind the datasource and fill the dataadapter.

Thanks in advance.

Private Sub cboApp_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles cboApp.SelectedIndexChanged

Dim selectSQL As String = "SELECT App, Name, Destination FROM
KickOffFTP WHERE (App = @app_param) order by Name"
Dim selectCMD As SqlCommand = New SqlCommand(selectSQL,
SqlConnection1)
remove()
Try

daFTPProcess.SelectCommand = selectCMD

selectCMD.Parameters.Add("@app_param", cboApp.Text)
'MsgBox(cboApp.Text)

'Fill, Reset and Fill dataset
'daFTPProcess = New SqlDataAdapter(selectSQL,
SqlConnection1)
'BindMyCombox()
'cboFTPProcess.DataSource = Nothing
'cboFTPProcess.DisplayMember = Nothing
'cboFTPProcess.Items.Clear()

'cboFTPProcess.DataSource = DsFTPProcess1
'cboFTPProcess.DisplayMember = "KickOffFTP.Name"
'daFTPProcess.SelectCommand = selectCMD
daFTPProcess.Fill(DsFTPProcess1)
Catch exc As Exception
' Display an error message.
MsgBox(exc.Message)
End Try

End Sub

Sub remove()

'MsgBox(cboFTPProcess.Items.Count)
Try
myIndex = cboFTPProcess.Items.Count
If myIndex > -1 Then
cboFTPProcess.DataSource = Nothing
Do While myIndex > 0 'Zero based
cboFTPProcess.Items.RemoveAt(0) 'Or...
'myCombo.Items.RemoveAt(myIndex) 'Beta 2 shows the
above line.
'Remove in reverse order, maybe items may move as
one is removed????
myIndex = myIndex - 1
Loop
cboFTPProcess.DataSource = DsFTPProcess1
End If
Catch exc As Exception
' Display an error message.
MsgBox(exc.Message)
End Try

End Sub
Nov 22 '05 #1
0 2890

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: stingrays | last post by:
Below is my code for a combobox. Basically, I have 2 comboboxes. 1 box is the application selection and the other retrieves data from the dataset (SQL Server) to populate the drop down in the...
1
by: Rachel Suddeth | last post by:
When I put a ComboBox on a form, I can enter strings through the designer to fill Items collections. I have put a ComboBox in a UserControl, and exposed the the Items collections with the same...
1
by: mdb | last post by:
I currently catch the SelectedIndexChanged event on a ComboBox to perform some processing when the user changes the selected item. But I also want to know when the user clears the list, but I...
5
by: feng | last post by:
In our VB.Net Windows form application we have a combobox pre-populated with a list of items. What I need is simply clear everything from it's dropdown, when a button is clicked. I tried...
1
by: feng | last post by:
The Combobox1.item.clear doesn't seem to work for me correctly. I have a Combox with a datasource bind to it. When I try to clear the Combobox with the following code: Combobox1.DataSource =...
1
by: Rob R. Ainscough | last post by:
What I'm trying to accomplish is: Disable a ComboBox (not bound to any data) when a .Clear method is executed. So far a cboComboBox.Items.Clear does NOT trigger any of the events I expected it...
13
by: KKuser | last post by:
Hello: I have 20, 30 text and combo boxes on one form, and I would like to clear them up at one time using the statement "With..........End With". I used this when using VB6, but I don't know...
6
by: Sakharam Phapale | last post by:
Hi All, How to fill one ComboBox from other ComboBox control? 1) Only setting the reference does the trick but doesn't show items in control. If you see in immediate window, it shows...
3
by: samoore33 | last post by:
I am populating a ComboBox at run time. I insert the first value of "Choose Value" cboTaxValue.Item.Insert(0, "Choose Value") Then I loop through the rest of the values to be added to the...
5
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
I want to create a customized ComboBox where the methods ComboBox.Items.Add and ComboBox.Items.Insert will behave thusly: -- If the item is not present, add it. -- If the item is present, set the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.