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

ComboBox binding to DataTable. SelectedValue problem...

Hi guys,
I have a comboBox binded to DataTable:
comboBox.DataSource = MyDataTable;

comboBox.ValueMember = "id";

comboBox.DisplayMember = "id";

Than in my code I need id = 3 to be selected in the comboBox. So I have a
code:

comboBox.SelectedValue = 3;

I don't have any event or any code after that may change the SelectedValue,
but in result I get wrong id shown in the comboBox!!!

Does anybody meet such a problem? How can I resolve it? What's wrong here?

Thanks a lot

Aleksey
Jun 29 '08 #1
1 4067
I think I know the problem reason. comboBox.Sort property for my ComboBox
was true. After I changed it to false everything works perfect. MS bug?
Comments...

"Aleksey Timonin" <al******@mdgmedical.comwrote in message
news:e%****************@TK2MSFTNGP03.phx.gbl...
Hi guys,
I have a comboBox binded to DataTable:
comboBox.DataSource = MyDataTable;

comboBox.ValueMember = "id";

comboBox.DisplayMember = "id";

Than in my code I need id = 3 to be selected in the comboBox. So I have a
code:

comboBox.SelectedValue = 3;

I don't have any event or any code after that may change the
SelectedValue, but in result I get wrong id shown in the comboBox!!!

Does anybody meet such a problem? How can I resolve it? What's wrong here?

Thanks a lot

Aleksey


Jun 29 '08 #2

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

Similar topics

0
by: Mohamed Osman | last post by:
If a bind a data table to a comboxbox as appose to merging the table into a dataset the selectedvalue property does not work consistently On loading of a form: A datatable is created from a...
1
by: Norma Zhao | last post by:
Hi, I have a ComboBox which data binding for the SelectedValue is set to a integer column of a data view. There are some null value in this column. When the binding column value changed in the...
1
by: Bruce | last post by:
Hi, there, I meet a problem about comboBox binding. -------------------- Database: Northwind Tables: 1) Products 2) Categories I create a form (named "form1") to edit the record from...
30
by: dbuchanan | last post by:
ComboBox databindng Problem == How the ComboBox is setup and used: My comboBox is populated by a lookup table. The ValueMember is the lookup table's Id and the DisplayMember is the text from a...
2
by: Nate | last post by:
I have used the feedback on this issue to remedy my comboboxes showing the first item on the list when a new record is added to the binding context --- Me.BindingContext(dsOrders,...
7
by: Simon Verona | last post by:
I posted this in dotnet.languages.vb.controls but thought I'd post here as well.. I have a combobox that is bound to a dataview generated from a dataset. The dataset has a single table...
3
by: amber | last post by:
Hello, I have 6 comboboxes, that I thought I could bind to the same datasource, and have them display different 'selectedvalue's', but apparently I can't... My code is as follows: dim drv as...
5
by: Peter M. | last post by:
I'm struggling with combobox databinding with something I consider a bug... I'm binding my combobox to an array of structs. The struct exposes two public properties, ID and Name, to be used as...
0
by: Frnak McKenney | last post by:
Can I use a bound ComboBox for both browsing and editing? I'm working on a small, standalone database application using Visual C#.NET 2003 and an Access data file. In order to keep the number...
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
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.