it means if user insert "n"(number of case) in textbox than click the "Next" button, in datagridview set to "n" number of rows. i don't know what code i use, please help me,
please check attach file, thank you so much

I would set datagrid's property AllowUserToAddRow to False and then manage to add a row by code. For example:

    Private Sub btnNext_Click(sender As System.Object, e As System.EventArgs) Handles btnNext.Click
        Try
            Dim caseNum As Int32 = 0
            If Int32.TryParse(tbCase.Text, caseNum) Then
                With DataGridView1
                    Dim index As Int32 = .Rows.Count
                    .Rows.Add()
                    .Rows(index).Cells(0).Value = caseNum
                End With
            End If
        Catch ex As Exception
            Throw ex
        End Try
    End Sub

Thank you so much for your reply,

private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                int caseNum = 0;
                if (int.TryParse(textBox2.Text, out caseNum))
                {
                    DataGridView dataGridView10 = new DataGridView();
                    int index = dataGridView10.RowCount;
                    dataGridView10.Rows.Add();
                    dataGridView10.Rows[index].Cells[0].Value = caseNum;

                }
               catch (Exception ex)
                {
                throw ex;
                }

is this right? in c#

Why do you create a new instance of DataGridView in DataGridView dataGridView10 = new DataGridView(); ?? You should employ the same DataGridView present in the form.

oh, i forgot

private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                int caseNum = 0;

                if (int.TryParse(textBox2.Text, out caseNum))
                {
                     nt index = dataGridView10.RowCount;
                    dataGridView10.Rows.Add();
                    dataGridView10.Rows[index].Cells[0].Value = caseNum;

                }

            }

but this code gives me error , Could you tell me which one is wrong?

It is always handy for us if you would tell us what the error message was you got.
EDIT:
Just guessing:
Line 11 you could try caseNum.ToString();

in line 13 ->

    Error   CS1524  Expected catch or finally

this error,

Oh, I see.
Well a try statement always has to be followed by at least a catch statement. See here for some explanation.
In your code I'd leave the try out. Your Tryparse method is sufficient here.

There is missing a catch instruction after line #15:

catch  
    {  
    } 

thank you so much :D ,

 private void button1_Click(object sender, EventArgs e)
        {

            try
            {
                int caseNum = 0;

                if (int.TryParse(textBox2.Text, out caseNum))
                {                 
                    dataGridView10.Rows.Add(caseNum);

                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

        }

this code is working correctly,
have a nice day.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.