Results 1 to 2 of 2

Thread: DataGrid problem?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2002
    Posts
    18

    DataGrid problem?

    I have a problem in my DataGrid.

    How to change the Column Header Text and Column Width?

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    Here you go:

    PHP Code:
    DataTable tblData = (DataTable)dataGrid1.DataSource;

    DataGridTableStyle tsMyStyle = new DataGridTableStyle();
    tsMyStyle.MappingName "MyTable"//MappingName should match the name of the table


    DataGridColumnStyle TextCol = new DataGridTextBoxColumn();
    TextCol.MappingName "Column1"//MappingName should match the name of the column
    TextCol.HeaderText "New Name of the Column";
    TextCol.Width 125;
    tsMyStyle.GridColumnStyles.Add(TextCol);

    TextCol = new DataGridTextBoxColumn();
    TextCol.MappingName "Column2"//MappingName should match the name of the column
    TextCol.HeaderText "Column2"//leave the same name
    TextCol.Width 50;
    tsMyStyle.GridColumnStyles.Add(TextCol);

    dataGrid1.TableStyles.Add (tsMyStyle); 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width