TextBox/ForLoop Help

  • Thread starter Thread starter Claude Grecea
  • Start date Start date
C

Claude Grecea

If anyone could help, I would greatly appreciated.

I am using a "For Loop" and thru each complete iteration I would like it to
stop and ask for user input, but I would not like to use a MessageBox.
Instead, I would like to use a Textbox. Is there a way for me to accomplish
this? Thanks in advance!

Claude
 
class MyUserInpurForm : Form { ....
TextBox textBox ....
}

MyUserInpurForm userInput = new MyUserInpurForm();
userInpur.ShowDialog();

The .ShowDialog will be wait until the form is closed.

Alex
http://devkids.blogspot.com
 
I'm assuming you are using Windows/WinForms and not web?

If so, you would need to put the text box on a form, then on the form you
could use the ShowDialog method of the form. When you call
[formnamehere].ShowDialog(... processing will stop in your loop until the
Hide or Close method of the form is called. Assuming you also had an OK
button on the form, in it's stuff the text box's text property into a new
property for the form, then call this.Hide. That way back in the loop you
can call the [formnamehere].mynewpropertyname to get what the user keyed in,
then [formnamehere].Close to close it.

I have to say though, calling a dialog box like that over and over is going
to make for a really bad user experience. You need to seriously rethink
this, and see if there's a better way to implement the interface. I know if
I were a user I wouldn't be happy about having this dialog pop up over and
over demanding info.

Robert
http://arcanecode.com
 
Yes, I am using a "WindowsForm", but I would not like to call a Dialog
because of same issue. What I would like to happen is every time the "For
Loop" goes thru each iteration to stop and wait for user input in the
"TextBox". Is there a method to call for this particular situation?

Claude


Arcane Code said:
I'm assuming you are using Windows/WinForms and not web?

If so, you would need to put the text box on a form, then on the form you
could use the ShowDialog method of the form. When you call
[formnamehere].ShowDialog(... processing will stop in your loop until the
Hide or Close method of the form is called. Assuming you also had an OK
button on the form, in it's stuff the text box's text property into a new
property for the form, then call this.Hide. That way back in the loop you
can call the [formnamehere].mynewpropertyname to get what the user keyed
in, then [formnamehere].Close to close it.

I have to say though, calling a dialog box like that over and over is
going to make for a really bad user experience. You need to seriously
rethink this, and see if there's a better way to implement the interface.
I know if I were a user I wouldn't be happy about having this dialog pop
up over and over demanding info.

Robert
http://arcanecode.com

Claude Grecea said:
If anyone could help, I would greatly appreciated.

I am using a "For Loop" and thru each complete iteration I would like it
to stop and ask for user input, but I would not like to use a MessageBox.
Instead, I would like to use a Textbox. Is there a way for me to
accomplish this? Thanks in advance!

Claude
 
Nope.

Text boxes must exist in something, that's what the forms are for.

You can, however, minimize the impact of the form by removing it's borders,
caption, etc, and making the text box take up 100% of the interior of the
form. Then it will LOOK like it's just a text box, but in fact be a text box
inside a form. That's the only way I know of for you to achieve the look you
want.

Arcane
http://arcanecode.com



Claude Grecea said:
Yes, I am using a "WindowsForm", but I would not like to call a Dialog
because of same issue. What I would like to happen is every time the "For
Loop" goes thru each iteration to stop and wait for user input in the
"TextBox". Is there a method to call for this particular situation?

Claude


Arcane Code said:
I'm assuming you are using Windows/WinForms and not web?
If so, you would need to put the text box on a form, then on the form you
could use the ShowDialog method of the form. When you call
[formnamehere].ShowDialog(... processing will stop in your loop until the
Hide or Close method of the form is called. Assuming you also had an OK
button on the form, in it's stuff the text box's text property into a new
property for the form, then call this.Hide. That way back in the loop
you can call the [formnamehere].mynewpropertyname to get what the user
keyed in, then [formnamehere].Close to close it.

I have to say though, calling a dialog box like that over and over is
going to make for a really bad user experience. You need to seriously
rethink this, and see if there's a better way to implement the interface.
I know if I were a user I wouldn't be happy about having this dialog pop
up over and over demanding info.

Robert
http://arcanecode.com

Claude Grecea said:
If anyone could help, I would greatly appreciated.

I am using a "For Loop" and thru each complete iteration I would like it
to stop and ask for user input, but I would not like to use a
MessageBox. Instead, I would like to use a Textbox. Is there a way for
me to accomplish this? Thanks in advance!

Claude
 
What you're wanting is essentially a terminal or console window.

Let me suggest a quick and dirty trick: Tell the compiler that your Windows
app is a console app. Then it will have a console window as well as the
other windows. On the console window, you can do Console.ReadLine() which
is a quick and simple way to get what you want. And, of course, you can
write in it and do other things to it with the other Console methods.

I'm going to have to give some thought to what you have to do to make a
regular textbox act like a console.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top