Click here to Skip to main content
15,922,166 members
Home / Discussions / C#
   

C#

 
AnswerAlso... Pin
Ravi Bhavnani18-Mar-06 18:07
professionalRavi Bhavnani18-Mar-06 18:07 
QuestionSimple question(i hope) about ComboBox Pin
e-laj18-Mar-06 11:24
e-laj18-Mar-06 11:24 
i have the folowing class:

class MyClass<br />
{<br />
	public MyClass(string str)<br />
	{<br />
		Str = str;<br />
	}<br />
<br />
	public string Str;<br />
<br />
	public override string ToString()<br />
	{<br />
		return Str;<br />
	}<br />
}


now lets add some items to a ComboBox:

comboBox1.Items.Add(new MyClass("aaa"));<br />
comboBox1.Items.Add(new MyClass("bbb"));<br />
comboBox1.Items.Add(new MyClass("ccc"));


and now....
suppose that i want to change the first item Str member to "ddd":
the following line doesn't work:

((MyClass)comboBox1.Items[0]).Str = "ddd";

But the following will work:

comboBox1.Items[0] = new MyClass("ddd");

It seems that a copy of the item is returned from the object collection in the ComboBox.
Does anyone know how it is possible to change the item directly without replacing it?

Thanks in advanced, Ilan
AnswerRe: Simple question(i hope) about ComboBox Pin
Ed.Poore18-Mar-06 12:49
Ed.Poore18-Mar-06 12:49 
GeneralRe: Simple question(i hope) about ComboBox Pin
e-laj18-Mar-06 13:25
e-laj18-Mar-06 13:25 
AnswerRe: Simple question(i hope) about ComboBox Pin
Guffa18-Mar-06 14:19
Guffa18-Mar-06 14:19 
GeneralRe: Simple question(i hope) about ComboBox Pin
e-laj18-Mar-06 14:31
e-laj18-Mar-06 14:31 
GeneralRe: Simple question(i hope) about ComboBox Pin
Ed.Poore18-Mar-06 22:26
Ed.Poore18-Mar-06 22:26 
GeneralRe: Simple question(i hope) about ComboBox Pin
e-laj19-Mar-06 2:57
e-laj19-Mar-06 2:57 
GeneralRe: Simple question(i hope) about ComboBox Pin
e-laj19-Mar-06 3:21
e-laj19-Mar-06 3:21 
GeneralRe: Simple question(i hope) about ComboBox Pin
Ed.Poore19-Mar-06 7:08
Ed.Poore19-Mar-06 7:08 
QuestionVirtual Network Adapter Pin
atmearman18-Mar-06 10:37
atmearman18-Mar-06 10:37 
AnswerRe: Virtual Network Adapter Pin
Ed.Poore18-Mar-06 11:03
Ed.Poore18-Mar-06 11:03 
GeneralRe: Virtual Network Adapter Pin
atmearman18-Mar-06 12:18
atmearman18-Mar-06 12:18 
GeneralRe: Virtual Network Adapter Pin
Ed.Poore18-Mar-06 12:43
Ed.Poore18-Mar-06 12:43 
Questionhow to show image in millimeters? Pin
valiovalio18-Mar-06 10:35
valiovalio18-Mar-06 10:35 
QuestionFile Upload using WebClient c# Pin
shamsallana18-Mar-06 10:28
shamsallana18-Mar-06 10:28 
AnswerRe: File Upload using WebClient c# Pin
Ed.Poore18-Mar-06 10:50
Ed.Poore18-Mar-06 10:50 
AnswerRe: File Upload using WebClient c# Pin
shamsallana19-Mar-06 22:23
shamsallana19-Mar-06 22:23 
Questionweb services and proxy Pin
DeathJester_18-Mar-06 10:20
DeathJester_18-Mar-06 10:20 
AnswerRe: web services and proxy Pin
Dave Kreskowiak19-Mar-06 6:40
mveDave Kreskowiak19-Mar-06 6:40 
QuestionConvert DateTine to a Number? Pin
redfish3418-Mar-06 10:03
redfish3418-Mar-06 10:03 
AnswerRe: Convert DateTine to a Number? Pin
Guffa18-Mar-06 10:27
Guffa18-Mar-06 10:27 
AnswerRe: Convert DateTine to a Number? Pin
Ravi Bhavnani18-Mar-06 18:05
professionalRavi Bhavnani18-Mar-06 18:05 
AnswerTHANKS!!! Pin
redfish3418-Mar-06 23:50
redfish3418-Mar-06 23:50 
QuestionDistributing C# Applications? Pin
Matt U.18-Mar-06 8:56
Matt U.18-Mar-06 8:56 

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.