PC Review


Reply
Thread Tools Rate Thread

ComboBox binding to DataTable. SelectedValue problem...

 
 
Aleksey Timonin
Guest
Posts: n/a
 
      29th Jun 2008
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


 
Reply With Quote
 
 
 
 
Aleksey Timonin
Guest
Posts: n/a
 
      29th Jun 2008
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" <(E-Mail Removed)> wrote in message
news:e%(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need flexibility when binding IEnumerable to ComboBox; still need DataTable? Ronald S. Cook Microsoft C# .NET 8 4th Feb 2008 10:02 PM
Why does a binding a combobox to datatable not work the same as da =?Utf-8?B?TW9oYW1lZCBPc21hbg==?= Microsoft Dot NET 0 27th Jan 2005 06:31 AM
Binding a combobox to a related DataTable Lorenz Kahl Microsoft ADO .NET 0 6th Sep 2004 04:24 PM
Bug when Binding a DataTable to a ComboBox using new MS Oracle DataAdapter Dextor Microsoft C# .NET 0 8th Sep 2003 04:06 PM
Binding a ComboBox to a DataTable Tony Microsoft Dot NET Framework Forms 0 22nd Jul 2003 08:33 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:40 AM.