locked
Checkbox column setting for datagridview RRS feed

  • Question

  •  

    I have a datagridview control bound to a datasource. Several of the columns are checkboxes. When the datagridview is populated it seems to automatically interpret the datasources columns of true's and false's and converts them into checkboxes. This is good. However, I wish to set the borderstyle to flatstyle for these columns/checkboxes.

     

    I've found examples where you create a new checkboxstyle column and you can set flatstyle quiet easily that way but my problem is how to make them flatstyle for an exsiting datagridview that has interpreted the data into checkbox columns already.

     

    Here's the method i'm using which makes some cosmetic changes to the datagridview already. I wish to make the checkbox borderstyle = flatstyle for columns 4 to 6

     

    Code Snippet

    private void PrepareGrid(int ExecID, int OrgID)

    {

    grdHistory.DataSource = _data.GetInvitationHistoryDetails(ExecID, OrgID);

    grdHistory.Columns[0].Visible = false;

    grdHistory.Columns[1].Width = 300;

    grdHistory.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;

    grdHistory.Columns[2].DefaultCellStyle.Format = "d MMM yyyy";

    grdHistory.Columns[3].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;

    grdHistory.Columns[4].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;

    if (OrgID == 0)

    {

    grdHistory.Columns[5].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;

    grdHistory.Columns[6].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;

    }

    }

     

     

    thanks,
    Saturday, March 29, 2008 10:03 AM

Answers

  • There is no way to convert the columns to the new checkbox column.  You need to remove the checkbox columns from the datagridview collection and add  columns of the new checkbox column in its place

     

    Saturday, March 29, 2008 10:40 AM

All replies

  • There is no way to convert the columns to the new checkbox column.  You need to remove the checkbox columns from the datagridview collection and add  columns of the new checkbox column in its place

     

    Saturday, March 29, 2008 10:40 AM
  • thought that might be the case, thanks

     

    Saturday, March 29, 2008 11:00 AM