I'm trying to bind a datagrid with some fields of a table of customers.
When I was working with ASP .Net, I used to fill an ArrayList with the instances of the customer class (each instance of the class 'clsCustomer' contains properties corresponding to fields in the customers table). It was easy to make that in ASP .Net since in design time I specify the columns of the datagrid and bind them with the corresponding properties in the datasource( which is an arraylist) and then, I bind programmatically the datagrid to that arraylist.
But when I moved to windows forms, I found that it was completely different. In fact, the possibility of binding columns in design time was not available. Moreover, I want to bind my datagrid to it datasource programatically. So, How should I proceed to have the desired columns bounded and not all of them (because if I write this:
'myDataGrid.DataSource=myArrayList', all the properties of the arraylist are bound and shown as columns in the datagrid)

defining and binding specific Columns in Datagrid
Argonautic
The columns you see when you set the datasource are the autogenerated ones, it auto setup a table style with all the columns of your datasource. You can't change the auto one at design time BTW.
Also, I know the reasons for doing arraylists and such in asp.net, though welcome to real fat applicaiton design, it's faster and better and well you can use datatables and datasets and such. Not so much to worry about like with web development, winforms apps by default perform much faster.
ghazi
You told me why shouldn't I use dataset; the reason for that is that I use calculated and formatted properties that does not correspond necessarly to fields in the database.
So I must (in my case) bind my datagrid to an arraylist.
For example: I have a Customers Table with the following fields: ('id','Name','Surname','Adress')
I wrote a class 'clsCustomer' and implemented in it the following properties: 'Id','Name','Surname','Adress' (Each property corresponds to a table field)
then, I wrote a function which fills and return an arraylist with instances of clsCustomer (Each instance corresponds to a line in the table 'customers').
I want my datagrid to show only the column 'Name'. So, I to bind it to this arraylist in this way:
dim myArray as arraylist=GetCustomersList() 'the function specified above
myDatagrid.datasource=myArray
And the result is that all the columns are shown.
I hope you've understood my case. What I insist on is that I want to bind my datagrid programmatically and not in design time nor using datatable or dataset.
Thank you again.
forteous
Create a new table style for the datagrid.
set the mapping of the table style along with any other options you want(Mapping most important).
Then add gridcolumnstyles to the gridcolumnstyles collection of your new tablestyle.
Make sure each gridcolumnstyle has the mapping name to the correct column.
then add your tablestyle to the tablestyles collection of the datagrid.
Check out this site for more information.
http://www.syncfusion.com/FAQ/WinForms/default.asp#44