Click here to Skip to main content
15,905,967 members
Home / Discussions / C#
   

C#

 
GeneralRe: System.WinForms Pin
Nnamdi Onyeyiri12-Jul-02 0:41
Nnamdi Onyeyiri12-Jul-02 0:41 
GeneralAgain IIS Pin
Mazdak11-Jul-02 5:18
Mazdak11-Jul-02 5:18 
GeneralRe: Again IIS Pin
Richard Deeming11-Jul-02 6:03
mveRichard Deeming11-Jul-02 6:03 
GeneralRe: Again IIS Pin
Mazdak11-Jul-02 9:29
Mazdak11-Jul-02 9:29 
GeneralListing Local Users Pin
Ben Swann11-Jul-02 4:29
Ben Swann11-Jul-02 4:29 
GeneralRe: Listing Local Users Pin
Richard Deeming11-Jul-02 5:44
mveRichard Deeming11-Jul-02 5:44 
GeneralRe: Listing Local Users Pin
Philip Fitzsimons11-Jul-02 12:00
Philip Fitzsimons11-Jul-02 12:00 
GeneralProblem with ComboBox.SelectedValue Pin
leppie11-Jul-02 3:57
leppie11-Jul-02 3:57 
Hi all,

ComboBox.SelectedValue dont seem to work correctly. Code:

... 
void SetupCustomers(){ //called from form constructor
cbCust.DataSource = dbase.GetCustomers(); //returns Customer[] from database
cbCust.DisplayMember = "Name"; // The name property
cbCust.ValueMember = "ID"; // The ID property (PK in database)
}
...


However when calling cbCust.SelectedValue returns the wrong value. Calling ((Customer)cbCust.SelectedItem).ID gives the correct answer.

This seems to be a problem with the DisplayMember being (automatically) sorted as all the returned SelectedValue's are within range.

EG : Customers[] expanded may look like this:

ID(Value) Name(Display)
20 Ben
21 John
23 Ann
26 Frank
27 Arnold

The combobox will display the Displaymembers in alphebetical order. Here is where the problem lies (i think Smile | :) ):

Value Display
20 Ann
21 Arnold
23 Ben
26 Frank
27 John

Now this is how Mr. ComboBox display and intepret Value and Display members, thus getting the mappings all wrong.

If anyone has had a similar experience or can spot where I made a mistake, please tell me Smile | :)

Thanking all replies in advance

Cheers Smile | :)

READ MSDN
GeneralRe: Problem with ComboBox.SelectedValue Pin
Chris Rickard11-Jul-02 8:54
Chris Rickard11-Jul-02 8:54 
GeneralRe: Problem with ComboBox.SelectedValue Pin
leppie11-Jul-02 9:29
leppie11-Jul-02 9:29 
GeneralRe: Problem with ComboBox.SelectedValue Pin
Chris Rickard11-Jul-02 10:16
Chris Rickard11-Jul-02 10:16 
GeneralRe: Problem with ComboBox.SelectedValue Pin
leppie11-Jul-02 10:46
leppie11-Jul-02 10:46 
GeneralSub-bitmap from bitmap Pin
Oyvind Bratland11-Jul-02 3:15
Oyvind Bratland11-Jul-02 3:15 
GeneralRe: Sub-bitmap from bitmap Pin
James T. Johnson11-Jul-02 19:08
James T. Johnson11-Jul-02 19:08 
GeneralRe: Sub-bitmap from bitmap Pin
Oyvind Bratland11-Jul-02 21:24
Oyvind Bratland11-Jul-02 21:24 
QuestionTreeView? Pin
Member 1697711-Jul-02 2:39
Member 1697711-Jul-02 2:39 
AnswerRe: TreeView? Pin
Oyvind Bratland11-Jul-02 2:48
Oyvind Bratland11-Jul-02 2:48 
GeneralRe: TreeView? Pin
Member 1697711-Jul-02 4:21
Member 1697711-Jul-02 4:21 
GeneralRe: TreeView? Pin
Eric Gunnerson (msft)11-Jul-02 7:17
Eric Gunnerson (msft)11-Jul-02 7:17 
Generalgetting the length of a closed MemoryStream Pin
shaunw11-Jul-02 1:21
shaunw11-Jul-02 1:21 
GeneralRe: getting the length of a closed MemoryStream Pin
Nish Nishant11-Jul-02 1:31
sitebuilderNish Nishant11-Jul-02 1:31 
GeneralRe: getting the length of a closed MemoryStream Pin
shaunw11-Jul-02 2:12
shaunw11-Jul-02 2:12 
GeneralIIS Pin
Mazdak10-Jul-02 20:53
Mazdak10-Jul-02 20:53 
GeneralRe: IIS Pin
James T. Johnson10-Jul-02 21:17
James T. Johnson10-Jul-02 21:17 
GeneralRe: IIS Pin
Mazdak10-Jul-02 22:16
Mazdak10-Jul-02 22:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.