List box question
Last post 05-07-2008 7:24 AM by rankief. 2 replies.
Sort Posts:
05-04-2008 11:04 PM
List box question

im writting a control out of the Listbox control provided. This control binds to different user defined types using ItemSource and DisplayMemberPath.

How do i get the selected item text from the listbox?? It returns an object and i do not know what is the type at each point.

rankief

Joined on 08-10-2006
Posts 6
05-05-2008 11:04 AM
Re: List box question

The selectedItem of a list box is the Data Object you bind to that row:

 YourDataObject data = Listbox.SelectedItem as YourDataObject;

if(data != null)

   // now you have access to all the field to your data for that row. If you want to find the text displayed, you access the field that bound to the display UI control

 

Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

sladapter

Joined on 03-05-2008
Indiana, US
Posts 404
05-07-2008 7:24 AM
Marked as Answer
Re: List box question

oh, i meant i dont know the type. it may be different type at different pages.

anyway i solved it by reflection. i forgot the existance of it! thanks alot dude

rankief

Joined on 08-10-2006
Posts 6