Click here to Skip to main content
15,897,371 members
Home / Discussions / C#
   

C#

 
GeneralRe: Overriding ToString Pin
monrobot1317-Mar-03 7:02
monrobot1317-Mar-03 7:02 
GeneralRe: Overriding ToString Pin
se99ts17-Mar-03 21:12
se99ts17-Mar-03 21:12 
GeneralRe: Overriding ToString Pin
Stephane Rodriguez.17-Mar-03 21:29
Stephane Rodriguez.17-Mar-03 21:29 
GeneralRe: Overriding ToString Pin
se99ts17-Mar-03 21:35
se99ts17-Mar-03 21:35 
GeneralRe: Overriding ToString Pin
Stephane Rodriguez.17-Mar-03 21:46
Stephane Rodriguez.17-Mar-03 21:46 
GeneralRe: Overriding ToString Pin
leppie17-Mar-03 6:04
leppie17-Mar-03 6:04 
GeneralRe: Overriding ToString Pin
monrobot1317-Mar-03 7:03
monrobot1317-Mar-03 7:03 
GeneralRe: Overriding ToString Pin
Wolfgang Loder18-Mar-03 1:55
Wolfgang Loder18-Mar-03 1:55 
Coming back to the original problem, you can also fill a listbox or combobox by setting the datasource to any object that implements the interface IList.
I had the problem,that I wanted the ValueMember property differently set to the DisplayMember. With the collections Add() method this is not possible.
So I defined a simple class:
internal class clsName
{
private string _longname;
private int _uid;
public string LongName {get {return _longname;} set {_longname = value;}}
public int UID {get {return _uid;} set {_uid = value;}}
public clsName (string lname, int uid)
{
_longname = lname;
_uid = uid;
}
}

and filled the combobox with an arraylist (the parameters come from a xml file):
[...]
_arrNames.Add(new clsName(nav2.Value,System.Convert.ToInt32(iterator.Current.GetAttribute("UID",nav.NamespaceURI))));
[...]
The combobox datasource can then be set to the arraylist and the members to the appropriate custom class properties.
[...]
cb.DataSource = _arrNames;
cb.DisplayMember = "LongName";
cb.ValueMember = "UID";
[...]

That's all and the list is filled with the strings plus the value is set to what I need in the combobox event handler later in the application.


Wolfgang

GeneralRe: Overriding ToString Pin
Don_s25-Mar-03 3:45
Don_s25-Mar-03 3:45 
GeneralWebServices and Security Pin
Braulio Dez17-Mar-03 5:13
Braulio Dez17-Mar-03 5:13 
GeneralRe: WebServices and Security Pin
Kannan Kalyanaraman17-Mar-03 17:56
Kannan Kalyanaraman17-Mar-03 17:56 
Generalform to form Pin
monrobot1317-Mar-03 4:56
monrobot1317-Mar-03 4:56 
GeneralRe: form to form Pin
Braulio Dez17-Mar-03 5:16
Braulio Dez17-Mar-03 5:16 
GeneralRe: form to form Pin
Anonymous19-Mar-03 1:34
Anonymous19-Mar-03 1:34 
QuestionSmall foot, BIG foot print???? Pin
codeweenie17-Mar-03 4:43
codeweenie17-Mar-03 4:43 
AnswerHere is the frmDateInput.cs contents Pin
codeweenie17-Mar-03 5:23
codeweenie17-Mar-03 5:23 
AnswerHere is the DateValidator.cs contents Pin
codeweenie17-Mar-03 5:26
codeweenie17-Mar-03 5:26 
AnswerRe: Small foot, BIG foot print???? Pin
leppie17-Mar-03 6:08
leppie17-Mar-03 6:08 
GeneralRe: Small foot, BIG foot print???? Pin
codeweenie17-Mar-03 6:19
codeweenie17-Mar-03 6:19 
GeneralRe: Small foot, BIG foot print???? Pin
leppie17-Mar-03 7:22
leppie17-Mar-03 7:22 
GeneralRe: Small foot, BIG foot print???? Pin
codeweenie17-Mar-03 7:31
codeweenie17-Mar-03 7:31 
GeneralRe: Small foot, BIG foot print???? Pin
leppie17-Mar-03 8:05
leppie17-Mar-03 8:05 
GeneralNon focus form Pin
Roger Alsing16-Mar-03 23:38
Roger Alsing16-Mar-03 23:38 
GeneralRe: Non focus form Pin
Rocky Moore17-Mar-03 1:34
Rocky Moore17-Mar-03 1:34 
GeneralRe: Non focus form Pin
Roger Alsing17-Mar-03 22:55
Roger Alsing17-Mar-03 22:55 

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.