Is it possible to use the "Create Collection" to fill with DataGrid? How do it?
Is it possible to use the "Create Collection" to fill with DataGrid? How do it?
Are you referring to a DataGridView control?
Is it possible to use the "Create Collection" to fill with DataGrid? How do it?
Yes!
Is it possible to use the "Create Collection" to fill with DataGrid? How do it?
Yes you can use a bindingSource to bind the dataGridView to a collection list in the same manner as I showed earlier for a combobox.
I am attaching a demo which binds the dataGridView to a collection list which is filled with objects of the gridData class. Since this class exposes its fields as properties they can individually be bound as columns within the dataGridView control. If you look at the columns defined for dataGridView1 you will see that the DataMember properties are set to these property names within the gridData class.
The following is the source code used in the project:
class-id bindwingrid.Form1 is partial
inherits type System.Windows.Forms.Form.
working-storage section.
method-id NEW.
procedure division.
invoke self::InitializeComponent
declare fl as type fillList = new fillList
set bindingSource1::DataSource to fl::getList
set dataGridView1::DataSource to bindingSource1::DataSource
goback.
end method.
method-id button1_Click final private.
procedure division using by value sender as object e as type System.EventArgs.
invoke self::Close
end method.
end class.
class-id gridData.
working-storage section.
01 custNo binary-long property.
01 custName string property.
01 custCompany string property.
end class.
class-id fillList.
select item-file assign to "C:\\bindwingrid\\bindwingrid\\itemfile.txt"
organization is line sequential
file status is file-status.
file section.
fd item-file.
01 item-record.
05 cust-no pic 9(3).
05 cust-name pic x(20).
05 cust-company pic x(20).
working-storage section.
01 file-status pic x(2) value spaces.
method-id getList.
local-storage section.
procedure division returning mylist as list[type gridData].
open input item-file
create mylist
perform until exit
read item-file
at end
exit perform
not at end
declare myitem as type gridData = new gridData
set myitem::custNo to cust-no
set myitem::custName to cust-name
set myitem::custCompany to cust-company
write mylist from myitem
end-read
end-perform
close item-file
goback.
end method.
end class.
Is it possible to use the "Create Collection" to fill with DataGrid? How do it?
Thank you
Sign up
Already have an account? Login
Welcome to the Rocket Forum!
Please log in or register:
Employee Login | Registration Member Login | RegistrationEnter your E-mail address. We'll send you an e-mail with instructions to reset your password.