开发者

How to Initilize a DataGridView and add Columns to it?

开发者 https://www.devze.com 2023-02-25 19:57 出处:网络
I can make a Button like this: Button buttonMinimize = new Button() { Size = new Size(40, 1开发者_StackOverflow中文版0),

I can make a Button like this:

    Button buttonMinimize = new Button()
    {
        Size = new Size(40, 1开发者_StackOverflow中文版0),
        BackgroundImageLayout = ImageLayout.Stretch,
        Location = new Point(10,10),
        TabStop = false,
    };

If I want to make a DataGridView in a same way: (see comments in code, the problem is there)

    DataGridView Passage = new DataGridView()
    {
        Columns = ??!//what should I write here to set my columns?
        //since Columns is a readonly property

    };


DatagridviewColumn is what you want http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcolumn.aspx


It's not an option to add columns in this way. Add them one by one.

passageGridView.Columns.Add("ColumnName", "ColumnHeader");
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号