Click here to Skip to main content
15,867,686 members
Home / Discussions / C#
   

C#

 
AnswerRe: Need Help on Writing to New Line Pin
Christian Graus1-May-08 19:32
protectorChristian Graus1-May-08 19:32 
AnswerRe: Need Help on Writing to New Line Pin
Luc Pattyn1-May-08 22:26
sitebuilderLuc Pattyn1-May-08 22:26 
QuestionComboBox in Datagrid view Pin
cocoonwls1-May-08 17:18
cocoonwls1-May-08 17:18 
AnswerRe: ComboBox in Datagrid view Pin
Gopal.S1-May-08 21:12
Gopal.S1-May-08 21:12 
GeneralRe: ComboBox in Datagrid view Pin
cocoonwls1-May-08 22:45
cocoonwls1-May-08 22:45 
QuestionMember Function Pointers usage on class instances: Pin
Net Guy1-May-08 17:14
Net Guy1-May-08 17:14 
AnswerRe: Member Function Pointers usage on class instances: Pin
Christian Graus1-May-08 17:19
protectorChristian Graus1-May-08 17:19 
QuestionReflection Question Pin
MrColeyted1-May-08 16:49
MrColeyted1-May-08 16:49 
Hello all! I have a college project due tomorrow and I am in dire need of some assistance! The project requires that I create a plain windows form with six controls on it; I have chosen six buttons. Form2 will be the startup form, will have a combobox and a DataGridView (I am using a richTextBox right now, but will change that once the rest works). The names of the controls from Form1 populate the combobox in Form2. By selecting one of the controls from the combobox, all of that controls' properties are then listed in the DataGridView.
I have most of it working, but I cannot get the value for each property using the GetValue(object, object[] index) method. I have tried all that I can think of, but cannot get it to work. Mad | :mad: Confused | :confused: The code that I have for Form2 is as follows:

Here, the main problem is on the bottom line of code. I have commented there.

public partial class Form2 : Form
{

//Declares an Array of type Controls:
Control[] controls;

public Form2()
{
InitializeComponent();
}

private void Form2_Load(object sender, EventArgs e)
{
//Creates an instance of Form1:
Form1 myForm = new Form1();

//Initializes the Control[] by calling the getControls() method on Form1:
controls = myForm.getControls();

//Adds the Control names to the ComboBox:
foreach (Control c in controls)
{
myCboBox.Items.Add(c.Name);
}
}

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();

//clears any previous entries:
richTextBox1.Clear();

foreach (PropertyInfo prop in t.GetProperties())
{
//Here, the GetValue method will not work! I have tried passing everything that I can think of to it
//and still it will not work. It keeps telling me that target object does not match.
//Please help.
richTextBox1.Text += "\n" +
prop.Name + "\t\t:" + prop.GetValue(t, null);
}
}
}

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

AnswerRe: Reflection Question Pin
PIEBALDconsult1-May-08 19:07
mvePIEBALDconsult1-May-08 19:07 
GeneralRe: Reflection Question Pin
MrColeyted1-May-08 19:22
MrColeyted1-May-08 19:22 
AnswerRe: Reflection Question Pin
J a a n s1-May-08 22:35
professionalJ a a n s1-May-08 22:35 
GeneralRe: Reflection Question Pin
MrColeyted1-May-08 23:00
MrColeyted1-May-08 23:00 
QuestionXSD class generation tool Pin
cbadal1-May-08 15:52
cbadal1-May-08 15:52 
AnswerRe: XSD class generation tool Pin
cbadal3-May-08 5:20
cbadal3-May-08 5:20 
AnswerRe: XSD class generation tool Pin
sri_00997-Jan-10 19:55
sri_00997-Jan-10 19:55 
Questionpassing argmumnet to cmd from and application Pin
Naveed7271-May-08 14:58
Naveed7271-May-08 14:58 
AnswerRe: passing argmumnet to cmd from and application Pin
Ennis Ray Lynch, Jr.1-May-08 15:03
Ennis Ray Lynch, Jr.1-May-08 15:03 
GeneralRe: passing argmumnet to cmd from and application Pin
Naveed7271-May-08 21:40
Naveed7271-May-08 21:40 
AnswerRe: passing argmumnet to cmd from and application Pin
Luc Pattyn1-May-08 22:36
sitebuilderLuc Pattyn1-May-08 22:36 
QuestionTransfer info from Form1 to Form2 Pin
nelsonpaixao1-May-08 14:35
nelsonpaixao1-May-08 14:35 
AnswerRe: Transfer info from Form1 to Form2 Pin
Christian Graus1-May-08 15:57
protectorChristian Graus1-May-08 15:57 
AnswerRe: Transfer info from Form1 to Form2 Pin
tika/ajay1-May-08 19:50
tika/ajay1-May-08 19:50 
GeneralRe: Transfer info from Form1 to Form2 Pin
Christian Graus1-May-08 21:37
protectorChristian Graus1-May-08 21:37 
AnswerRe: Transfer info from Form1 to Form2 Pin
Bhim Prakash Singh2-May-08 0:12
Bhim Prakash Singh2-May-08 0:12 
QuestionRe: Transfer info from Form1 to Form2 Pin
nelsonpaixao4-May-08 16:35
nelsonpaixao4-May-08 16:35 

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.