Click here to Skip to main content
15,892,927 members
Home / Discussions / C#
   

C#

 
AnswerRe: C# Program Output?? Pin
Nelson Costa Inácio13-Oct-15 6:53
Nelson Costa Inácio13-Oct-15 6:53 
AnswerRe: C# Program Output?? Pin
Pete O'Hanlon13-Oct-15 7:02
mvePete O'Hanlon13-Oct-15 7:02 
QuestionRe: C# Program Output?? PinPopular
Paul Conrad13-Oct-15 7:13
professionalPaul Conrad13-Oct-15 7:13 
AnswerRe: C# Program Output?? Pin
John Torjo19-Oct-15 22:09
professionalJohn Torjo19-Oct-15 22:09 
Questionc Pin
User 1202214013-Oct-15 5:12
User 1202214013-Oct-15 5:12 
QuestionRe: c# Pin
Paul Conrad13-Oct-15 5:19
professionalPaul Conrad13-Oct-15 5:19 
AnswerRe: c Pin
Richard MacCutchan13-Oct-15 7:56
mveRichard MacCutchan13-Oct-15 7:56 
Questionre-cast of Control back to its Native Type ? Pin
BillWoodruff13-Oct-15 0:48
professionalBillWoodruff13-Oct-15 0:48 
Windows Forms

Let'say you have a List<Control> : some of those Controls' Native Types have the 'FlatStyle Property; others may have the 'BorderStyle Property; other Controls may have neither. Of course we know that the Button Control, for example, inherits from ButtonBase which inherits from Control, etc.

At run-time we can use reflection to determine if a Control is of a Type that contains a specific Property, and, if the Property exists, get its DeclaringType:
C#
PropertyInfo pif = currentControl.GetType().GetProperty("BorderStyle");

if (pif != null)
{
    Type typ = pif.DeclaringType;
}
If we want to set the 'BorderStyle of the Control at this point, obviously we have to cast it, somehow, back to its Native Type.

But, how ?

thanks, Bill
«I want to stay as close to the edge as I can without going over. Out on the edge you see all kinds of things you can't see from the center» Kurt Vonnegut.

AnswerRe: re-cast of Control back to its Native Type ? Pin
Pete O'Hanlon13-Oct-15 1:14
mvePete O'Hanlon13-Oct-15 1:14 
GeneralRe: re-cast of Control back to its Native Type ? Pin
BillWoodruff13-Oct-15 2:06
professionalBillWoodruff13-Oct-15 2:06 
GeneralRe: re-cast of Control back to its Native Type ? Pin
Pete O'Hanlon13-Oct-15 2:21
mvePete O'Hanlon13-Oct-15 2:21 
GeneralRe: re-cast of Control back to its Native Type ? Pin
BillWoodruff13-Oct-15 3:01
professionalBillWoodruff13-Oct-15 3:01 
AnswerRe: re-cast of Control back to its Native Type ? Pin
Eddy Vluggen13-Oct-15 1:42
professionalEddy Vluggen13-Oct-15 1:42 
GeneralRe: re-cast of Control back to its Native Type ? Pin
BillWoodruff13-Oct-15 2:18
professionalBillWoodruff13-Oct-15 2:18 
GeneralRe: re-cast of Control back to its Native Type ? Pin
Eddy Vluggen13-Oct-15 3:41
professionalEddy Vluggen13-Oct-15 3:41 
QuestionGet rows from database, Entity framework Pin
Member 1204569212-Oct-15 1:49
Member 1204569212-Oct-15 1:49 
AnswerRe: Get rows from database, Entity framework Pin
Dave Kreskowiak12-Oct-15 4:36
mveDave Kreskowiak12-Oct-15 4:36 
GeneralRe: Get rows from database, Entity framework Pin
Member 1204569212-Oct-15 4:48
Member 1204569212-Oct-15 4:48 
GeneralRe: Get rows from database, Entity framework Pin
Dave Kreskowiak12-Oct-15 4:50
mveDave Kreskowiak12-Oct-15 4:50 
GeneralRe: Get rows from database, Entity framework Pin
Member 1204569212-Oct-15 5:09
Member 1204569212-Oct-15 5:09 
GeneralRe: Get rows from database, Entity framework Pin
Dave Kreskowiak12-Oct-15 5:14
mveDave Kreskowiak12-Oct-15 5:14 
GeneralRe: Get rows from database, Entity framework Pin
Member 1204569212-Oct-15 9:35
Member 1204569212-Oct-15 9:35 
GeneralRe: Get rows from database, Entity framework Pin
Dave Kreskowiak12-Oct-15 9:54
mveDave Kreskowiak12-Oct-15 9:54 
GeneralRe: Get rows from database, Entity framework Pin
Member 1204569212-Oct-15 10:30
Member 1204569212-Oct-15 10:30 
GeneralRe: Get rows from database, Entity framework Pin
Dave Kreskowiak12-Oct-15 10:33
mveDave Kreskowiak12-Oct-15 10:33 

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.