ValueMember = This ?

  • Thread starter Thread starter Tony Maresca
  • Start date Start date
T

Tony Maresca

I am binding a combo box to an ArrayList of
objects with a property called "Name" that is
assigned to DisplayMember.

How can I have the SelectedValue of the combo
return the instance of the object whose Name
property is selected in the combo?

I know that I can add a property like this:

public class MyObject
{
public MyObject Value {get{return this;}}
}

And set ValueMember to "Value".

But, I was wondering if there was any special
designation I could just set ValueMember to,
since I don't always work with my own objects
or non-sealed objects, and hence, can't always
add the property.

--
Tony M.
 
Tony said:
I am binding a combo box to an ArrayList of
objects with a property called "Name" that is
assigned to DisplayMember.

How can I have the SelectedValue of the combo
return the instance of the object whose Name
property is selected in the combo?

I know that I can add a property like this:

public class MyObject
{
public MyObject Value {get{return this;}}
}

And set ValueMember to "Value".

But, I was wondering if there was any special
designation I could just set ValueMember to,
since I don't always work with my own objects
or non-sealed objects, and hence, can't always
add the property.

do you want the SelectedItem property?

Hans Kesting
 
Hans,
I don't know. I'm not sure I understand where I would need that in
Control.Invoke. But I am anxious to see your example.
Thanks,
Trint

.Net programmer
(e-mail address removed)
 
Trint said:
Hans,
I don't know. I'm not sure I understand where I would need that in
Control.Invoke. But I am anxious to see your example.
Thanks,
Trint

Net programmer
(e-mail address removed)

I meant, instead of trying to get SelectedValue to return the item,
you could use SelectedItem which already returns the selected item
(as an "object").

Hans Kesting
 
Back
Top