Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting user input

Status
Not open for further replies.

jmofthenorth

Technical User
May 8, 2007
7
US
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




 
perhaps something like this
Code:
 GetInfo newForm = new GetInfo(s);
 newForm.ShowDialoge(this); // wait here for user input

 // form has closed so get the propertie
 sampleNumber = newForm.SampleNumber;

in the GetInfo class just set the var before closing
hope this helps

Age is a consequence of experience
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top