I need a quick text input dialog box (MessageBox with a single text box in it). Is there any control available or should I use a form?
I just want user to enter some ID. And in other occasion I want 2 texboxes for username and password.
Microsoft.VisualBasic.dll has an InputBox method which you can use from C# to get a single string.
For example (Add a reference to Microsoft.VisualBasic.dll first)
using Microsoft.VisualBasic;
string response = Interaction.InputBox("Enter a string:", "MyApp", "DefaultString", 0, 0);
Othewise, you'll have to make your own form.
simple one is inputbox
Related
I'm making a little password generator and I want it to lock the output text box to 10 characters, so that when the user clicks the password genenerate button it does not just continue with an endless line of randomly generated passwords.
How can I do this?
There's a control on the text box in Visual Studio.
If you click the button and they go into properties there should be something called "max length". Set that to however long you want it.
You can use Substring() function to cut the extra characters in your generated password.
For an instance
string GeneratedPassword = "1234567891345678";
textBox1.Text = GeneratedPassword.Substring(0,10);
Also the textBox1.MaxLength = 10 will not give you the desired result. It will only limit input of the character manually in the textbox. It will not limit input of characters programmatically.
Can somebody help me to find the text box identity so that I can pass texts to each of the text boxes in an opened pop-up window? I tried to find differences in each of the textboxes I found all have similar control types, I tried using "SearchProperties". I am quite new to Selenuim.
Code:
this.UserNameTextBox.SearchProperties[WinControl.PropertyNames.ControlType] = "Edit";
this.UserNameTextBox.SearchProperties[WinControl.PropertyNames.ClassName] = "WindowsForms10.*"; // WindowsForms10.* is not it`s complete name, I dont want mention it`s complete name.
PS: I don't want to use "UITestControlCollection" functionality for some purpose.
I got a question:
I'm writing a short program, which the user is typing in his/her name, age and adsress. after that, the user will click the "Load Data" button i created. then their address etc. will be listed in a new form. and now i got a "Google Maps" button. so when they click the "google maps" button, it should open their browser on google maps and pointing at the address they typed in. someone got an idea?
cheers
The current structure for Google Maps urls is (source):
http://maps.google.com/maps?t=m&q=Location
So in order to do this, you would want to (assuming that you are using ASP.net):
On a click event for the GoogleMaps button, concatenate the address fields together
Use this structure to create a maps url using this in the q parameter (be sure to Html Encode)
Response.Redirect(googleMapsUrl);
I have a form in which there are various labels and a button..on the button click event there is a code written which generates a cs file in which i want the text of the label to be displayed..
I am trying to get the values with the help of the following function in the code dom but m not able to extract the values of the label i.e. i am just getting label1.text, label2.text, etc. instead i want the values that are there in the labels and the combobox..
can anyone please help..
start.Statements.Add(new CodeVariableReferenceExpression("Info.Valid("\"combobox1.SelectedValue.ToString()\"", "\"label1.Text\"", "\"label2.Text\"", "\"label3.Text\"", "\"numericupdown.Value.ToString()\"")");
here start is the CodeMemberMethod to which all the statements are to be added, Info is another class and Valid is a method to which i need to pass all these values as arguments..
Thats right, your code shouldnt extract any values because you specifies text constants. You may use string.Format method to prepare text data. Try something like below:
string pattern = "Info.Valid(\"\"{0}\"\", \"\"{1}\"\", \"\"{2}\"\", \"\"{3}\"\", \"\"{4}\")";
string data = string.Format(pattern,
combobox1.SelectedValue.ToString(),
label1.Text,
label2.Text,
label3.Text,
numericupdown.Value.ToString());
start.Statements.Add(new CodeVariableReferenceExpression(data));
For more details check out this
I am creating a form in C# and need to display text on the form. I need some of the text to show up in a bulleted, unordered list. Is it possible to do this while using a label? Or a rich text box? I am not using ASP.NET and this is for a desktop app.
My message should look like this:
To continue please selected one of the actions below:
Click ButtonA to do this action.
Click ButtonB to do this action.
Thanks!
Just to add as a suggestion to the OP, I have found that using a StringBuilder to construct multi-line messages helps me keep the formatting straight:
StringBuilder messageBuilder = new StringBuilder(200);
messageBuilder.Append("To continue, please select one of the actions below:");
messageBuilder.Append(Environment.NewLine);
messageBuilder.Append(Environment.NewLine);
messageBuilder.Append("\t\u2022 Click Button A to do this action.");
messageBuilder.Append(Environment.NewLine);
messageBuilder.Append("\t\u2022 Click Button B to do this action.");
MessageBox.Show(messageBuilder.ToString());
You can use ASCII or UniCode characters, and reformat your string to replace a marker character with the formatting character.
Say you defined your string like so:
var myMessage = "To continue please selected one of the actions below: * Click ButtonA to do this action. * Click ButtonB to do this action."
you could do a Regex.Replace that looked for asterisks and converted to bullets:
var formattedString = Regex.Replace(myMessage, "\*", "\r\n \u2022");
Since the string was defined on one line, we also put in a newline ("\r\n").
If you'll take a look at the Character Map (Start > Programs > Accessories > System Tools > Character Map), you can locate the keystroke "code" for most characters.
For Arial Text, the "Middle Dot" keystroke combination is:
Alt+0183
To place this in your text using Visual Studio, hold down the Alt key while typing in "0183" on the Numeric Keypad (not the keys over the alpha pad).
This should give you "·" in your text.
That's as close as I have come.
Note that other special characters (degrees - Alt+0176 °, copyright - Alt+0169 ©, and many others) can be included with this technique.
Yes you can use text below:
const string text = #"To continue please selected one of the actions below:
. Click ButtonA to do this action.
. Click ButtonB to do this action.";
label1.Text = text;
You can use special characters for the bullet as well such as *.
You could use a WebBrowser control. I.E.:
WebBrowser webBrowser1 = new WebBrowser();
webBrowser1.DocumentText 1 = "<li>Click ButtonA ...</li><li>Click ButtonB ...</li>"