Quantcast
Channel: Visual COBOL - Forum - Recent Threads
Viewing all articles
Browse latest Browse all 4356

RE: listBox (sample C#)

$
0
0

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:

setColumn1::HeaderTextto"Column1"
setColumn1::MaxInputLengthto 10
setColumn1::Nameto"Column1"

 *> Column2

setColumn2::HeaderTextto"Column2"
setColumn2::MaxInputLengthto 10
setColumn2::Nameto"Column2"

etc.


Viewing all articles
Browse latest Browse all 4356

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>