display custom column names in datagrid
-
hi i am working in a windows form in C#. i have a datagrid which displays values from the table in the database. i know how to assign custom headers or rather to change the column names. now suppose i change the ordering of the columns, how will can i set the column names respectively without keeping a track of their order. for eg. if my datagrid is such table name:software master softwareid softwaredesc remarks and i have given column names for them in the datagrid keeping their order into consideration as code description remarks now if the secondcolumn is to be shown as the third column,how can i change it so that even the custom column names are rearranged accordingly. plss help i have to create a common method which is to be called by more than form. in that case the columns of the grid are changing always.:confused::sigh: regards sukanya
-
hi i am working in a windows form in C#. i have a datagrid which displays values from the table in the database. i know how to assign custom headers or rather to change the column names. now suppose i change the ordering of the columns, how will can i set the column names respectively without keeping a track of their order. for eg. if my datagrid is such table name:software master softwareid softwaredesc remarks and i have given column names for them in the datagrid keeping their order into consideration as code description remarks now if the secondcolumn is to be shown as the third column,how can i change it so that even the custom column names are rearranged accordingly. plss help i have to create a common method which is to be called by more than form. in that case the columns of the grid are changing always.:confused::sigh: regards sukanya
One way is to use aliases for columns in SQL query itself. e.g. the query can be SELECT Softwareid as Code, softwaredesc as description, remarks as remarks FROM SoftwareMaster Cheers Ravindra Sadaphule MCSD.NET