Skip to main content

HI, I have a cobol program which returns me the array in a copybook when I pass that copy book to form and try to load that array in datagridview the value is getting changed.

e.g  The Copy Book Variable is declared

01 S PIC S9(9)V99 occurs 15 times

and when I am binding it to grid inside a loop

invoke dgv::Rows::Add(S(counter))


#COBOL
#COBOLVISUALCOBOLMIGRATION

HI, I have a cobol program which returns me the array in a copybook when I pass that copy book to form and try to load that array in datagridview the value is getting changed.

e.g  The Copy Book Variable is declared

01 S PIC S9(9)V99 occurs 15 times

and when I am binding it to grid inside a loop

invoke dgv::Rows::Add(S(counter))


#COBOL
#COBOLVISUALCOBOLMIGRATION

The default format for a column is simply a text format so numeric data will not contain any formatting characters such as decimal points, commas etc.

In order to get the columns to be formatted correctly you need to set the DefaultCellStyle::Format property. You can do this within the Forms Designer by editing the column and clicking on the DefaultCellStyle option and populating the Format property with a predefined type or with a custom formatting mask.

You can also do this within code like:

          set dataGridView1::Columns::Item(0)::DefaultCellStyle::Format to "N2"

          perform varying sub1 from 1 by 1 until sub1 > 3

             invoke dataGridView1::Rows::Add(S(sub1))

          end-perform

N2 is the predefined type for numeric with 2 decimal places.


HI, I have a cobol program which returns me the array in a copybook when I pass that copy book to form and try to load that array in datagridview the value is getting changed.

e.g  The Copy Book Variable is declared

01 S PIC S9(9)V99 occurs 15 times

and when I am binding it to grid inside a loop

invoke dgv::Rows::Add(S(counter))


#COBOL
#COBOLVISUALCOBOLMIGRATION

Thanks the formatting issue is resolved but now if the value is 200.00 it is displaying as 20011.00 and if it is 16.25 then it is displaying as 1625.00


HI, I have a cobol program which returns me the array in a copybook when I pass that copy book to form and try to load that array in datagridview the value is getting changed.

e.g  The Copy Book Variable is declared

01 S PIC S9(9)V99 occurs 15 times

and when I am binding it to grid inside a loop

invoke dgv::Rows::Add(S(counter))


#COBOL
#COBOLVISUALCOBOLMIGRATION

I am afraid that I will need to see an example in order to resolve this as I do not experience the same behavior here with a simple demo.

Can you attach a simple demo that demonstrates the problem?


HI, I have a cobol program which returns me the array in a copybook when I pass that copy book to form and try to load that array in datagridview the value is getting changed.

e.g  The Copy Book Variable is declared

01 S PIC S9(9)V99 occurs 15 times

and when I am binding it to grid inside a loop

invoke dgv::Rows::Add(S(counter))


#COBOL
#COBOLVISUALCOBOLMIGRATION

S has PIC S9(9)V99 which is not a .Net object. Define S as decimal or move S before '::Rows::Add' to a decimal varialbe.


HI, I have a cobol program which returns me the array in a copybook when I pass that copy book to form and try to load that array in datagridview the value is getting changed.

e.g  The Copy Book Variable is declared

01 S PIC S9(9)V99 occurs 15 times

and when I am binding it to grid inside a loop

invoke dgv::Rows::Add(S(counter))


#COBOL
#COBOLVISUALCOBOLMIGRATION

thnx