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");
精彩评论