checkbox check with text in a label [closed] - c#

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

Related

Windows form application c# [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 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();
}
}

Count number of clicks on picture box [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 7 years ago.
Improve this question
With each click on the picture box the number in the output label must decrement by one.
You need an event handler for the clicking of the image, and an int to keep track of how many times it was clicked; here is some pseudocode to get you started:
int timesClicked = 42;
private void Img_Click(sender object, eventargs e)
{
timesClicked--;
UpdateLabel();
}
internal void UpdateLabel()
{
label.Caption = timesClicked.ToString();
}

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();
}
}

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);
}
}

How to allow only valid values in a combobox? [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 9 years ago.
Improve this question
in C# with DotNet 4 i have a form with a combobox which is filled with values when starting the program.
Now user can dropdown and select one of the values.
But: It is also possible to write something new into the combobox-field.
Question: What can i do that it is NOT possible to write something which is not part of the list?
Thanks
To make the text portion of a ComboBox non-editable, set the DropDownStyle property to "DropDownList".
It can be done by simply assigning a property to combobox .DropDownStyle = ComboBoxStyle.DropDownList. but, this property do not allow to edit text. means you have to select item either by mouse or by up/down arrow key. You cannot filter result by selecting this property. if you wish to filter result but don't allow to accept invalid value then you can do this by writing some code in cmb_Validating event
private void cmb_Validating(object sender, CancelEventArgs e)
{
if (cmb.SelectedValue == null && cmb.Text != string.Empty)
e.Cancel=true;
}

Categories