DataGrid Column Properties
-
Hi, Can anyone tell me how to change column name and column width for a DataGrid (Windows.Forms) that is not bound to a DataSet (i.e. not using DataGrid.TableStyles?) Thanks in Advance, [EDIT] Actually, I just figured out how to edit the names by accessing my DataTable, and figured out how to create a TableStyle dynamically: DataGridTableStyle myGridTableStyle = new DataGridTableStyle(); However, Help, says you must first create a new DataGridColumnStyle per the table. This: DataGridColumnStyle myGridColumnStyle = new DataGridColumnStyle(); isn't available, though. Compiler error: Cannot create an instance of the abstract class or interface 'System.Windows.Forms.DataGridColumnStyle' So, anyone know how to get around this? I know I have to use DataGridColumnStyle's to change the width of the column, but if I can't create a DataGridColumnStyle I'm at a loss...(And like I said in the original post: no, I can't use the GUI to accomplish this because I'm not using a DataSource via DataSet, etc.) [/EDIT] -Idealius
-
Hi, Can anyone tell me how to change column name and column width for a DataGrid (Windows.Forms) that is not bound to a DataSet (i.e. not using DataGrid.TableStyles?) Thanks in Advance, [EDIT] Actually, I just figured out how to edit the names by accessing my DataTable, and figured out how to create a TableStyle dynamically: DataGridTableStyle myGridTableStyle = new DataGridTableStyle(); However, Help, says you must first create a new DataGridColumnStyle per the table. This: DataGridColumnStyle myGridColumnStyle = new DataGridColumnStyle(); isn't available, though. Compiler error: Cannot create an instance of the abstract class or interface 'System.Windows.Forms.DataGridColumnStyle' So, anyone know how to get around this? I know I have to use DataGridColumnStyle's to change the width of the column, but if I can't create a DataGridColumnStyle I'm at a loss...(And like I said in the original post: no, I can't use the GUI to accomplish this because I'm not using a DataSource via DataSet, etc.) [/EDIT] -Idealius
The DataGridColumnStyle class has over 10 abstract methods, thus cannot be instantiated. The compiler lists the methods that need implementation. Either you provide (default) implementation, or you may just as well use one of the two ready-to-use derived classes. In MSDN, click on the DataGridColumnStyle item in the TOC, you'll see the class hierarchy, which lists : DataGridBoolColumn and DataGridTextBoxColumn.