The Add method on the Columns collection property does not take a string as a parameter, it takes an object of type DataGridViewColumn. You need to create the column objects first and then add them to the grid. The easiest way to see how this is done is to let the designer do this for you and then look at the code that is generated (or just let the designer do it for you) If you open up the datagridview tasks in design mode (click small arrow on top right of control) you will see a link named Add Columns. You can specify the details for each of the columns here. The designer will then generate the required code and place it in the .designer.cbl file. It should look something like the following: set dataGridView1 to new System.Windows.Forms.DataGridView set Column1 to new System.Windows.Forms.DataGridViewTextBoxColumn set Column2 to new System.Windows.Forms.DataGridViewTextBoxColumn set Column3 to new System.Windows.Forms.DataGridViewTextBoxColumn and then further down there will be a method for adding these new columns to the grid: invoke dataGridView1::Columns::AddRange(table of type System.Windows.Forms.DataGridViewColumn(Column1 Column2 Column3)) The column properties will then be set accordingly: set Column1 :: HeaderText to "Column1" set Column1 :: MaxInputLength to 10 set Column1 :: Name to "Column1" * Column2 set Column2 :: HeaderText to "Column2" set Column2 :: MaxInputLength to 10 set Column2 :: Name to "Column2" etc.
↧