简体   繁体   中英

How to Insert UserControl TextBox to DataGridView in C#?

In Sql Server 2005, In Form Load I write this Code. txtPrprCase is a UserControl and validates First Character to Capital. How to i add this Control to DataGridView. I try the Following Code. But it does not Work.

ciscontrols.txtPrprCase txt = new ciscontrols.txtPrprCase();
        txt.Name = "Customer Name";
        this.dataGridView2.RowCount = 1;
        foreach (DataGridViewRow row in dataGridView2.Rows)
        {
            row.Cells[0].Value = txt;
        }

and the following code works the validation

ciscontrols.txtPrprCase txt = new ciscontrols.txtPrprCase();
this.dataGridView2.Rows.add(txt);

it works but it does not contain column header and row header...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM