Graph in C # with Datagridview data

3

Hi, you could advise me or give me ideas on how to work with this, what I need is to insert a numeric value in the textbox and that this value is inserted inside the DataGridView and inserted into the value column and where it says password go auto increasing the number and likewise the data will be shown in a Chart control.

    
asked by karol 01.11.2016 в 20:30
source

2 answers

2

For the workflow, it seems obvious to me

1. Create an event in the Add button ...

Double-click the OK button to create a method automatically.

private void btnAceptar_Click(object sender, EventArgs e)
{

}

All code in this method will be executed each time you press the Add button. Here we will do the next point ...

2. Insert the TextBox value in the DataGridView ...

It would be nice if here (in the button method) you validate that the TextBox value is not empty, that it has no letters, etc.

Insert in the DataGridView a new row with the index, and the value that is in the TextBox as they indicated in another answer

this.midataGridView.Rows.Add(claveSiguiente, textBoxValor.Text);

Within this same method of the button you add the value of the TextBox to the bar graph

mibarChart1.Series[0].Points.Add(Convert.ToInt32(textBoxValor.Text));
    
answered by 04.11.2016 / 23:40
source
1

As I see in the image you only have two columns in your DataGridView, when you want to add, you have to add the entire row even if it is an empty data in the following way.

     miDataGrid.Rows.Add(mitextbox.Text, mitextbox2.Text);

With this add rows to your DataGridView.

    
answered by 01.11.2016 в 21:58