jmofthenorth
Technical User
Hi,
I am in the middle of creating my first app in C# and am hung up on an area I suspect is actually really simple. I have a Windows form and am running an event, loading data that I am retrieving from files the users selected. Because the user selects multiple files at once, I need to be able to match the files to their respective objects that I have already initialised. Essentially, I have 9 samples and if none of the sample names match the filenames I would like to request the user to input which sample the particular file is referring to. Ideally I would just open up something like a messagebox that would say "Enter the sample # corresponding to file *.*" The user would then type in the # and click enter, the messagebox would close and the program would continue running. My problem is that I can't seem to create my own windows application that returns an entered integer. the code I have looks somthing like
foreach(sample s in unmatchedSamples)
{
GetInfo newForm = new GetInfo(s);
newForm.Show();
while(newForm.UserEntered)
{;} //wait for user to enter data
sampleNumber = newForm.SampleNumber;
//get sample number
//Then more code to assign the number to the file
//which I'll exclude
newForm.Dispose();
}
so that was in my main form then I have the code for another form, GetInfo, which is just a blank form with a label, textbox, and a button that say OK
it also contains the properties
public int SampleNumber
{
get{return Convert.ToInt16(Textbox1.Text)}
}
private bool userEntered = false;
public bool UserEntered
{
get{return userEntered;}
set{userEntered = Value;}
}
and the event
private void button1_clicked(object sender, eventArgs e)
{
this.UserEntered = true;
this.Hide();
}
I see why this doesn't work, but I hope that it atleast explains what I am trying to do. Any help would be greatly appreciated.
Jesse
I am in the middle of creating my first app in C# and am hung up on an area I suspect is actually really simple. I have a Windows form and am running an event, loading data that I am retrieving from files the users selected. Because the user selects multiple files at once, I need to be able to match the files to their respective objects that I have already initialised. Essentially, I have 9 samples and if none of the sample names match the filenames I would like to request the user to input which sample the particular file is referring to. Ideally I would just open up something like a messagebox that would say "Enter the sample # corresponding to file *.*" The user would then type in the # and click enter, the messagebox would close and the program would continue running. My problem is that I can't seem to create my own windows application that returns an entered integer. the code I have looks somthing like
foreach(sample s in unmatchedSamples)
{
GetInfo newForm = new GetInfo(s);
newForm.Show();
while(newForm.UserEntered)
{;} //wait for user to enter data
sampleNumber = newForm.SampleNumber;
//get sample number
//Then more code to assign the number to the file
//which I'll exclude
newForm.Dispose();
}
so that was in my main form then I have the code for another form, GetInfo, which is just a blank form with a label, textbox, and a button that say OK
it also contains the properties
public int SampleNumber
{
get{return Convert.ToInt16(Textbox1.Text)}
}
private bool userEntered = false;
public bool UserEntered
{
get{return userEntered;}
set{userEntered = Value;}
}
and the event
private void button1_clicked(object sender, eventArgs e)
{
this.UserEntered = true;
this.Hide();
}
I see why this doesn't work, but I hope that it atleast explains what I am trying to do. Any help would be greatly appreciated.
Jesse