i am trying to use SendKeys.Send() to send textbox1.Text to a application ( like notepad ), and i want to disable or remove spaces from the textbox so there is no spaces in the application.
Any help is appreciated!
private void InfoSend_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(3000);
SendKeys.Send(input_info);
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
input_info = textBox1.Text;
}
If user can input white spaces to TextBox then you can write this:
private void InfoSend_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(3000);
input_info = input_info.Replace(" ", string.Empty);
SendKeys.Send(input_info);
}
Related
I have a textbox. In that textbox I write Human. Then I click a button, and if the word is human, then on a richtextbox, the word human will appear.
Here's the code I've tried.
private void button3_Click(object sender, EventArgs e)
{
if (textBox4.Text)
{
richTextBox1.Text = "human";
}
}
private void textBox4_TextChanged(object sender, EventArgs e)
{
string value = textBox4.Text;
}
I tried making the textbox into a string so I could use it in the if statement, but it didn't work, so instead I used texbox4.text, but it is still wrong.
You could simply do with this piece of code,
private void button1_Click(object sender, EventArgs e)
{
if(textBox1.Text =="human")
{
richTextBox1.Text = textBox1.Text;
}
}
My application has one button one text box and a webbrowser control which is going to navigate at google.com at form load event.
If I am setting the text attributes to the google textbox in webBrowser1_DocumentCompleted method after clicking the button I am able to invoke google search button.
private void Form1_Load(object sender, EventArgs e)
{
webBrowser1.Navigate("https://www.google.co.in/?gfe_rd=cr&ei=u6PkV4X9LovZ8Aec7bI4&gws_rd=ssl");
webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);
}
void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
textElement = webBrowser1.Document.All.GetElementsByName("q")[0];
textElement.SetAttribute("value", "facebook");
}
private void btnLogin_Click(object sender, EventArgs e)
{
ele = webBrowser1.Document.All.GetElementsByName("btnK")[0];
ele.InvokeMember("click");
}
If I am setting the text attributes to the google textbox in btnLogin_Click method after clicking the button i am not able to invoke google search button.
private void Form1_Load(object sender, EventArgs e)
{
webBrowser1.Navigate("https://www.google.co.in/?gfe_rd=cr&ei=u6PkV4X9LovZ8Aec7bI4&gws_rd=ssl");
webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);
}
void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
textElement = webBrowser1.Document.All.GetElementsByName("q")[0];
}
private void btnLogin_Click(object sender, EventArgs e)
{
textElement.SetAttribute("value", "facebook");
ele = webBrowser1.Document.All.GetElementsByName("btnK")[0];
ele.InvokeMember("click");
}
Where I am going wrong please suggest me.
Hi I'm very new to C# and I was just writing a very basic code could anyone help me out? I am trying to simply show a variable (inputted by the user via the textbox) show up in the message box... Thanks :)
private void button1_Click(object sender, EventArgs e)
{
string name1 = textBox1.Text;
MessageBox.Show = (name1);
textBox1.Text = ("");
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
string name1 = textBox1.Text;
}
It's a method, not a property, so you need to call it using this syntax
MessageBox.Show(name1);
Related, textBox1.Text is a string property so you need to change that syntax to
textBox1.Text = "my string";
Your click event could be rewritten as this:
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show(textbox1.Text);
textBox1.Text = "";
}
and this section of code doesn't actually have any significance. name1 is only in scope inside the text changed event handler, and you do nothing with it.
private void textBox1_TextChanged(object sender, EventArgs e)
{
string name1 = textBox1.Text;
}
I want to show different labels output from DropDownList with button
select Item on DropDownList and click button to show output in label
Can anyone help me out on this?
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = DropDownList1.SelectedValue;
}
just write down this in button click event
protected void Button1_Click(object sender, EventArgs e) {
label.text = ComboBox.SelectedText;
}
protected void Button1_Click(object sender, EventArgs e)
{
lable1.Text=DropDownList1.SelectedValue.ToString();
}
or u can do
protected void Button1_Click(object sender, EventArgs e)
{
String input=DropDownList1.SelectedIndex >= 0 ? DropDownList1.SelectedItem.ToString() : "";
lable1.Text=input;
}
As the titles suggest I am interested in obtaining the value from 4 combo boxes. All 4 combo boxes are the same in the that they list numbers from 0-9. I would like to take those numbers and assigning them to a single string variable. So for example if users selects (CB1 = 4)(CB2 = 3) (CB3 = 2) (CB4 = 1) I would like to take those selection and assign them to a string variable. Thanks in Advance.
-Nogard
if you are using winforms
string s"";
private void combobox1_SelectedIndexChanged(object sender, EventArgs e)
{
s = combobox1.Text+ combobox2.Text+ combobox3.Text+ combobox4.Text;
}
private void combobox2_SelectedIndexChanged(object sender, EventArgs e)
{
s = combobox1.Text+ combobox2.Text+ combobox3.Text+ combobox4.Text;
}
private void combobox3_SelectedIndexChanged(object sender, EventArgs e)
{
s = combobox1.Text+ combobox2.Text+ combobox3.Text+ combobox4.Text;
}
private void combobox4_SelectedIndexChanged(object sender, EventArgs e)
{
s = combobox1.Text+ combobox2.Text+ combobox3.Text+ combobox4.Text;
}
or call only a selected index change event in all comboboxes since all are doing same