DataGridView need guidance with that [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 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();
}
}

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

CS1525 C# Invalid expression term 'string' [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 4 years ago.
Improve this question
I have this error and I have no ideo about what should I do
The aim is when I click to button, it should read the word in textbox and save it into the string variable by its new factor.I have the error oin the topic
private void panel_button_kelimeekle_kaydet_Click(object sender, EventArgs e)
{
if(panel_checkbox_ing.Checked)
{
string (panel_textbox_kelimeekle_yab.Text) = Ingkelimeler[(Ingkelimeler.Length+1)];
}
}
If panel_textbox_kelimeekle_yab is already a textbox on your form, then you don't need to declare its type when you assign a value to it. C# thinks you're trying to declare a new string variable.
Change that line of code to
panel_textbox_kelimeekle_yab.Text = Ingkelimeler[(Ingkelimeler.Length+1)];
This probably won't solve all your problems, but at least it will get you on to the next error message. (You probably mean Length-1 in your array index, but there's really no way for us to know.)

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

Call a class in Visual studio through a button [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 this project in my visual studio and i have a form which is linked to a solution in a project.
So, i need to call it on a button click.
It's like:
private void button1_Click(object sender, EventArgs e)
{
poComp.Client.StartpoComp
}
The thing is i have not copied the code the right way, houw should it proceed?
What is the file's structure?
Sorry, i know this might sound dumb and it probably is but i'm right in the beginning.
Below will do what (I think) you want to do but I strongly advise that you google "using classes c#" to try and find some tutorials
Here is just one
private void button1_Click(object sender, EventArgs e)
{
StartpoComp spc = new poComp.Client.StartpoComp();
//myFormsLabel.Text = spc.SomePublicVariable;
//spc.SomePublicMethod(param1);
}

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