Click here to Skip to main content
16,020,377 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi I have form with some text box,button,...and data grid view
in this form I have one combo Box stuff name and 4 text box (description,unit price,count,date)one of this text box is
count i want for example user enter count=24 ,user can enter 24 serial number and
stuff name,description,unit price,count,...is not change and after user click insert button all 24 record save in data grid view.

I can write a program that user enter one record then insert another record
my data grid view has columns (stuff name,unit price,date,...)that in rows this record mustn't change in 24 record
but serialNo. of record is different.
Posted
Updated 2-Aug-11 0:39am
v2
Comments
Sergey Alexandrovich Kryukov 2-Aug-11 3:07am    
Is it a question? :-)
--SA
lilipoot 100 2-Aug-11 4:31am    
thanks for your answer
but i want when text box count=24 we have 24 rows in my data grid view and when
user press enter key in serial number ,serial number save in data grid view and
other columns of data grid view (count,stuff name,unit price,...)is not change
and show in the data grid view.

1 solution

If i read you right, then you want to give the user the chance to enter a number of serial numbers, and then enter a new row in your DataGridView for each of these, with the same information from the text boxes for each row?

If so, it's pretty simple.

Assuming your serial numbers are specific, rather than a range, and your users eneter then in a text box, separated by a ',' character:
C#
private void button1_Click(object sender, EventArgs e)
    {
    TextBox tbSerials, tbDescription, tbUnitPrice, tbCount, tbDate;
    DataGridView myDataGridView = new DataGridView();
    string[] serialNos = tbSerials.Text.Split(',');
    foreach (string sn in serialNos)
        {
        if (!string.IsNullOrEmpty(sn))
            {
            myDataGridView.Rows.Add(sn, tbDescription, tbUnitPrice, tbCount, tbDate);
            }
        }
    }
 
Share this answer
 
Comments
lilipoot 100 2-Aug-11 5:10am    
thanks for your answer but i want when text box count=24 we have 24 rows in my data grid view and when user press enter key in serial number ,serial number save in data grid view and other columns of data grid view (count,stuff name,unit price,...)is not change and show in the data grid view.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900