2
Reply

Add data to dataGridView

Mike Jonson

Mike Jonson

13y
4.2k
0
Reply

    There are two ways to add data 1) By assigning an Object of Datatable/Hashtable/arraylist etc to the 'Datasource' Property of GridView 2) Or, manually add rows and values to GridView

    Hi!

    There is a problem: He created the following event handler:

    private void bOk_Click(object sender, EventArgs e)
            {
                DebitEnter me = new DebitEnter();

                float income;
                float.TryParse(tbSumm.Text, out income);

                me.Debit = income;
                me.DateEnter = dateTimePicker_Debit.Value;
                me.Category = tbCategory.Text;
                me.Description = textBox_Description.Text;

                //add debit in table
                fdebit.AddDebit(me);
            }

    Created a method:

    //add debit in table
    public void AddDebit(DebitEnter me)
            {
                dataGridView_Debit.Rows.Add(me.Category, me.Description, me.Debit, me.DateEnter);

            }

    But when I press the button in datagridviev nothing is added. Why can not understand? Please, help!