Click here to Skip to main content
15,915,513 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: dotnetfx2 Pin
sas94912-May-08 10:57
sas94912-May-08 10:57 
AnswerRe: dotnetfx2 Pin
Thomas Stockwell2-May-08 10:57
professionalThomas Stockwell2-May-08 10:57 
QuestionWord Viewer .OCX ???? Pin
devboycpp2-May-08 7:54
devboycpp2-May-08 7:54 
AnswerRe: Word Viewer .OCX ???? Pin
Pete O'Hanlon2-May-08 8:30
mvePete O'Hanlon2-May-08 8:30 
QuestionMissing The Point Pin
Oddball2-May-08 6:10
Oddball2-May-08 6:10 
AnswerRe: Missing The Point Pin
Thomas Stockwell2-May-08 11:02
professionalThomas Stockwell2-May-08 11:02 
GeneralRe: Missing The Point Pin
Oddball2-May-08 11:22
Oddball2-May-08 11:22 
QuestionReflection Question Pin
MrColeyted1-May-08 22:41
MrColeyted1-May-08 22:41 
Hello all. I am in dire need of some help. I have a project that I need to complete STAT! Here is the rundown:
I have a form. This form has six controls on it. They do nothing.
I have another form that retrieves these these control in a Control[] array.
On this second form, there is a comboBox and a richTextBox.
The comboBox is populated with the names of the controls.
I have absolutely no problem getting the names of the properties; I can get them fine.
I cannot get the value of each of these properties. I know that there is a GetValue(object, object[] index) method that is supposed to return the value of a property, but I can not get it to work to save my life!Confused | :confused:

I have included the code from the SelectedIndexChanged event of the combobox, and the class that represents a property below. Assume that the rest of the program works because it does.
If the GetValue call is dropped off the end of the last line below, all of the properites' names are properly listed in the textBox.

Please show me how I should call this method. Any sugestions would be greatly appreciated!Cool | :cool:

private void myCboBox_SelectedIndexChanged(object sender, EventArgs e)
{


//creates an int to hold the selected index:
int index = myCboBox.SelectedIndex;

//creates a type variable:
Type t = controls[index].GetType();

MyProperty Myproperty = new MyProperty(t.Name, null);

PropertyInfo[] myProps = t.GetProperties();

foreach (PropertyInfo p in myProps)
{
richTextBox1.Text += "\n" +
//The GetValue call is whats killing me!
//Throws a TargetException
//Going crazy here! Please help!
p.Name + "\t\t\t\t" +p.GetValue((object)Myproperty, null);
}
}
}

public class MyProperty
{
public MyProperty(string aName, object aValue)
{
theName = aName;
theValue = aValue;
}
private static string theName;

public static string theNameProp
{
get { return theName; }
set { theName = value; }
}

private static object theValue;

public static object intTest2
{
get { return theValue; }
set { theValue = value; }
}
}

"If you don't know where you're going, you'll probably end up somewhere else." Yogi Berra

QuestionRe: Reflection Question Pin
Urs Enzler2-May-08 4:28
Urs Enzler2-May-08 4:28 
AnswerRe: Reflection Question Pin
Fayu5-May-08 13:46
Fayu5-May-08 13:46 
QuestionCXX0017: Error: symbol "hr" not found Pin
nilam24771-May-08 22:06
nilam24771-May-08 22:06 
AnswerRe: CXX0017: Error: symbol "hr" not found Pin
Mike Dimmick2-May-08 6:08
Mike Dimmick2-May-08 6:08 
QuestionWhy .net code is in .h File not in .cpp file Pin
Abhijit D. Babar1-May-08 20:06
Abhijit D. Babar1-May-08 20:06 
AnswerRe: Why .net code is in .h File not in .cpp file Pin
Urs Enzler2-May-08 4:31
Urs Enzler2-May-08 4:31 
QuestionNeed for a rich Text Editor .... Pin
devboycpp1-May-08 19:12
devboycpp1-May-08 19:12 
AnswerRe: Need for a rich Text Editor .... Pin
Christian Graus1-May-08 19:32
protectorChristian Graus1-May-08 19:32 
AnswerRe: Need for a rich Text Editor .... Pin
Vasudevan Deepak Kumar2-May-08 0:44
Vasudevan Deepak Kumar2-May-08 0:44 
AnswerRe: Need for a rich Text Editor .... Pin
Reelix6-May-08 22:53
Reelix6-May-08 22:53 
QuestionChange Directory type info Pin
coleydog1-May-08 13:12
coleydog1-May-08 13:12 
QuestionStrange Behavior with Generics Pin
girijaa30-Apr-08 6:09
professionalgirijaa30-Apr-08 6:09 
AnswerRe: Strange Behavior with Generics Pin
Urs Enzler1-May-08 10:12
Urs Enzler1-May-08 10:12 
QuestionUnsafe Assembly Permissions Pin
Brady Kelly30-Apr-08 5:15
Brady Kelly30-Apr-08 5:15 
QuestionDataTable.Select() Pin
alex.almeida30-Apr-08 3:24
alex.almeida30-Apr-08 3:24 
QuestionTableDataAdapter.Update to two mirror databases... [modified] Pin
sabr4930-Apr-08 2:07
sabr4930-Apr-08 2:07 
QuestionForce TextBox to show cursor Pin
Christian Wikander29-Apr-08 23:00
Christian Wikander29-Apr-08 23:00 

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.