Set datagrid view background to transparent

后端 未结 5 1620
萌比男神i
萌比男神i 2020-12-11 07:04

I tried to set the background color of a data grid view to be \"transparent\" from properties but it it said \"not a valid property\".

How can I do it?

5条回答
  •  情歌与酒
    2020-12-11 07:33

    Having a transparent color in the DataGridView BackGroundColor property is not possible.

    So I decided to sync this property with the parent's BackColor. The good old databinding feature of WinForms is very good at this :

    myDataGridView.DataBindings.Add(nameof(DataGrid.BackgroundColor), 
                                    this, 
                                    nameof(Control.BackColor));
    

    Just after InitializeComponents();

    I know this is pretty old, but this works very well.

提交回复
热议问题