Windows form application c# [closed] - c#

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I am designing a windows form application in c# visual studio. for example i have three textboxes Textbox1 texbox2 and textbox3 i want that when user type a number (integer or float) in textbox1 it is automatically added to the values entered in textbox2 when he press enter and displayed in textbox3 .also texbox1 and 2 clears when the numbers are added in textbox3 , how can i do that ?? thanks in advance.

Can you try this(I think you are wrongly tagged wpf):
//please use Property Window to generate this event
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
this.textBox2.Text += this.textBox1.Text;
this.textBox1.Clear();
}
}

Related

checkbox check with text in a label [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 days ago.
Improve this question
This is for C# in visual studios.
This is what i'm wanting to do...
If a label contains any information (value or words) to check the check box.
The label is hidden, and if there is any containing value in label I want the checkbox to be true.
this is my code but it's working?!?
private void checkbox_CheckedChanged(object sender, EventArgs e)
{
if (lblName.Enabled = true)
{
chkLX125.Checked = true;
}
else { MessageBox.Show("Error: Please enter value before proceeding.", "Selection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
chkLX125.Checked = false;}
}
Clearly label shouldn't be true. How should I tell the code, if label contains value to check the box?
Sometimes the simple things get me lol.
Thank you for taking the time to read/help me

Detect when none of app windows is active/focused [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
How detect when user changes focus from multi-window application (alt+tab e.g.).
I want to detect when none of the app windows is active/focused.
First window is always shown but user can work with up to four windows(none of these is shown as dialog).
Form has a ContainsFocus property that indicates whether the form, or one of its child controls has the input focus. You can check this property for all open forms to detect if the application contains focus or not:
var isActive = Application.OpenForms.Cast<Form>().Any(x=>x.ContainsFocus);
Also as another option:
var isActive = (Form.ActiveForm != null)
If you want to be notified of the state of the application you can handle Activate and Deactivate event of your forms for all forms.
private void f_Deactivate(object sender, EventArgs e)
{
BeginInvoke(new Action(() =>
{
if (Form.ActiveForm == null)
Text = "App Deactivated.";
else
Text = "Still Active";
}));
}

DataGridView need guidance with that [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Thank you for your time in advance, I need some help, I want to create a DataGridView in Windows form, and in this grid I want to enter data and when I hit enter it should save that data to database and create another line, I tried to find a good tutorial on it but didn’t succeeded. if there is any good example please let me know
And please I do NOT need the grid with save update etc buttons, It should save data upon hit enter and cursor moves to the next line of the grid
If there is any tutorial or example please let me know
You simply catch the Enter-key in the DataGridView.KeyDown event:
private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
yourSaveRoutine();
dataGridView1.Rows.Add();
}
}

How can receive data from usb barcode Scanner in Form_KeyPress Event and put it in a textbox Automatically? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
i have an application with C# , and i need to get data from barcode scanner and Recive it in Form_KeyPress Event and put it in a textbox automatic .
Barcode scanner working like keyboard. Open text document and read text with barcode. If it is working try same on textbox. texbox will active in that time. and you can use textchange event.
something like this:
private string barcode = string.Empty;
private Form_KeyPress(object sender, KeyPressEventArgs e)
{
if (ev.KeyChar == '\r')
{
textBox.Text = barcode;
barcode = string.Empty;
}
barcode += e.KeyChar
}

clear the fields on a win form on click event [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Hi Guys. I am working on a project using visual studio C#, and here is an image of my win form now what i an doing is entering the value in the fields o this form and saving the to my database but after reloading this form all the previous values are there. want i want is that when i click the SAVE button in this form it must save all the values in my database and then clear all the previous values in the text fields + radio buttons etc.
Please help me what will be the code for this process and where should i write this code?
private void btnSaveCick(object sender,EventArgs e)
{
//save your data here
//after saving your data call the CLearControls() function
ClearControls(this);
}
void ClearControls(Control control)
{
foreach (Control c in control.Controls)
{
if (c is TextBox)
((TextBox)c).Clear();
else if (c is RadioButton)
((RadioButton)c).Checked = false;
else if (c is ComboBox)
((ComboBox)c).SelectedIndex = -1;
if(c.HasChildren)
ClearControls(c);
}
}

Categories