简体   繁体   中英

How to add a column of One row of same size in datagridview?

I have created a Data Grid View in Visual studio using c#. It has three columns. Now I want to add a new column at the end containing list data. Column with one row of size of the Data Grid View table. Grayed one in the image I have created yellow part I have to add.

在此处输入图片说明

You could to do not draw a Top border for that column. Something like this:

    private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
    {
        e.AdvancedBorderStyle.Bottom = DataGridViewAdvancedCellBorderStyle.None;
        if (e.ColumnIndex == 3 && e.RowIndex > 1)
        {
            e.AdvancedBorderStyle.Top = DataGridViewAdvancedCellBorderStyle.None;
        }
    }

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