473,327 Members | 1,920 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,327 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 2885

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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.