473,382 Members | 1,392 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,382 software developers and data experts.

combobox bug???

dotnet framework v1.0.3705 in vs 2002
code below
whats happening

when I select something else than first element in my combobox and then I do
a combobox1.selectindex = -1 the first element is selected
so instead of being -1 it is 0 (checked with debugger)
if the first element is checked and I do combobox1.selectindex = -1, then
nothing is selected (normal)
the thing is that I have to call ComboBox1.SelectedIndex = -1 twice
but also the indexchanged event is raised twice (unkewl)

somebody saw this problem?


code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim table As DataTable
table = New DataTable()
table.Columns.Add("id")
table.Columns.Add("name")
table.Rows.Add(New Object() {1, "one"})
table.Rows.Add(New Object() {2, "two"})
table.Rows.Add(New Object() {3, "much more"})
ComboBox1.DataSource = table
ComboBox1.DisplayMember = "name"
ComboBox1.ValueMember = "id"
ComboBox1.SelectedIndex = -1
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
ComboBox1.SelectedIndex = -1
End Sub
Nov 20 '05 #1
2 1016
Hi,

The only way I found to do it is in a thread.
With ComboBox1

.DataSource = ds.Tables(0)

.DisplayMember = "Name"

.ValueMember = "id"

End With

Dim trdChange As New System.Threading.Thread(AddressOf ChangeComboIndex)

trdChange.Start()

Private Sub ChangeComboIndex()

ComboBox1.SelectedIndex = -1

End Sub

Ken

------------------------

"Dominique Vandensteen" <domi.vds_insert@tralala_tenforce.com> wrote in
message news:uU**************@TK2MSFTNGP09.phx.gbl...
dotnet framework v1.0.3705 in vs 2002
code below
whats happening

when I select something else than first element in my combobox and then I
do
a combobox1.selectindex = -1 the first element is selected
so instead of being -1 it is 0 (checked with debugger)
if the first element is checked and I do combobox1.selectindex = -1, then
nothing is selected (normal)
the thing is that I have to call ComboBox1.SelectedIndex = -1 twice
but also the indexchanged event is raised twice (unkewl)

somebody saw this problem?


code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim table As DataTable
table = New DataTable()
table.Columns.Add("id")
table.Columns.Add("name")
table.Rows.Add(New Object() {1, "one"})
table.Rows.Add(New Object() {2, "two"})
table.Rows.Add(New Object() {3, "much more"})
ComboBox1.DataSource = table
ComboBox1.DisplayMember = "name"
ComboBox1.ValueMember = "id"
ComboBox1.SelectedIndex = -1
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
ComboBox1.SelectedIndex = -1
End Sub

Nov 20 '05 #2
Cor
Hi Dominique,

I did not see that code of you made it new.

When I try this the behaviour it is as I would expect.

This is with 2003 so when not, we can try it again.

I hope this helps you

Cor

Dim bool As Boolean
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim dt As New DataTable
Dim dc1 As New DataColumn("A")
dt.Columns.Add(dc1)
Dim adt() As String = {"Belgie", "Nederland", "Luxemburg"}
For i As Integer = 0 To adt.Length - 1
Dim dr As DataRow = dt.NewRow
dr(0) = adt(i)
dt.Rows.Add(dr)
Next
Me.ComboBox1.BeginUpdate()
Me.ComboBox1.DisplayMember = "A"
Me.ComboBox1.ValueMember = "A"
Me.ComboBox1.DataSource = dt
Me.ComboBox1.EndUpdate()
Me.ComboBox1.SelectedIndex = -1
bool = True
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender _
As Object, ByVal e As System.EventArgs) Handles
ComboBox1.SelectedIndexChanged
If bool Then
MessageBox.Show(Me.ComboBox1.Text & "|" & _
Me.ComboBox1.SelectedIndex.ToString)
Me.ComboBox1.SelectedIndex = -1
End If
End Sub
///


Nov 20 '05 #3

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

Similar topics

13
by: Mr. B | last post by:
Here's the situation... You've a combobox with Items already added. Say they look like this (or even lines of text): 10-00-232 10-00-256 10-01-006 10-01-213 10-02-200
7
by: Nicolae Fieraru | last post by:
Hi All, I am trying to change the rowsource of a combobox when I click on it. I played with many events, associated with the form and the combobox, but still haven't figured out what is the way...
8
by: Zlatko Matię | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
1
by: anonymous | last post by:
I've been trying to put a them, please help me out. Here's the major parts of my code: public Form1() { DataSet myDataSet = new DataSet("myDataSet"); DataTable testTable = new...
3
by: TT (Tom Tempelaere) | last post by:
Hay there, I'm writing my own DataGridComboBoxColumn because .NET 1.1 does not have one (I hope .NET 2.0 supplies one). I based it on this article:...
2
by: Don | last post by:
I've looked high and low for some code that will allow me to have a combobox with a flat borderstyle. I found a few examples, but nothing that was really usable for me. I had the following...
4
by: jon f kaminsky | last post by:
Hi- I've seen this problem discussed a jillion times but I cannot seem to implement any advice that makes it work. I am porting a large project from VB6 to .NET. The issue is using the combo box...
6
by: dbuchanan | last post by:
VS2005 I've been reading all the help I can on the topic (MSDN, other) but I can't make sense of this. Desired behavior; The user is to choose from the displayed list of the databound combobox...
1
by: polocar | last post by:
Ciao a tutti, leggendo qua e lą per il forum ho scoperto che non sono l'unico ad avere questo problema. Se si inserisce un controllo ComboBox in un form di C#, non č possibile impostare la sua...
5
by: Rich | last post by:
Hello, I have a search application to search data in tables in a database (3 sql server tables). I populate 2 comboboxes with with data from each table. One combobox will contain unique...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.