views:

34

answers:

1

Hi,

I created the custom winforms data control which has the "DisplayMember & ValueMember" properties (the functionality should be same as in standard winforms controls). But the problem is common and can be used in webforms.

Now, I'm trying get values via Reflection and DataRow/DataRowView. Should be supported more ways how to get/set values? Should I handle some special situations? Is there some best practise how to do this task?

Thanks.

+1  A: 

Can you inherit from ListControl? This will do all the heavy lifting for you. If not try reflecting the ListControl class and see how that handles it.

Martin Harris
No, I can't inherit from UserControl.
TcKs
You can't inherit from UserControl? You wouldn't be, you'd be inheriting from ListControl (which inherits from Control). If you meant you *must* inherit from UserControl then your best bet is to follow my second suggestion and look at the way the framework does it be using reflector to look at the code in ListControl.
Martin Harris
Sorry, my mistake. I can't inherit from ListControl because I inherit from UserControl.I searched for the code you have recomend, but I didn't found anything special what is different from current code (using DataRow/DataRowView or PropertyInfor/FieldInfo).
TcKs