DataGrid Column Width

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • frank

    #1

    DataGrid Column Width

    How do I set the column width of a column in a DataGrid programatically (in
    ASP.NET web pages)?

    I understand I may have to use DataGridTableSt yle, but I can't get this to
    work with web pages.

    Any help would be appreciated.


  • Saravana

    #2
    Re: DataGrid Column Width

    you can programmaticall y change width of the column like this,

    datagrid1.Colum ns(0).ItemStyle .Width.Pixel(15 0)

    or

    datagrid1.Colum ns(0).ItemStyle .Width = new Unit(150,UnitTy pe.Pixel)


    --
    Saravana
    Microsoft India Community Star,
    MCAD,SE,SD,DBA.


    "frank" <frank@frank.co m> wrote in message
    news:#mvRZp2TDH A.2312@TK2MSFTN GP12.phx.gbl...[color=blue]
    > How do I set the column width of a column in a DataGrid programatically[/color]
    (in[color=blue]
    > ASP.NET web pages)?
    >
    > I understand I may have to use DataGridTableSt yle, but I can't get this to
    > work with web pages.
    >
    > Any help would be appreciated.
    >
    >[/color]


    Comment

    • Ignacio Machin

      #3
      Re: DataGrid Column Width

      Hi Frank,

      You can use DataGrid.Column s[X].ItemStyle.Widt h , here goes an example:
      this.locationgr id.Columns[2].Visible = this.locationgr id.Columns[3].Visible
      = false;

      this.locationgr id.Columns[1].ItemStyle.Widt h= 460;



      Hope this help,

      --
      Ignacio Machin,
      ignacio.machin AT dot.state.fl.us
      Florida Department Of Transportation

      "frank" <frank@frank.co m> wrote in message
      news:%23mvRZp2T DHA.2312@TK2MSF TNGP12.phx.gbl. ..[color=blue]
      > How do I set the column width of a column in a DataGrid programatically[/color]
      (in[color=blue]
      > ASP.NET web pages)?
      >
      > I understand I may have to use DataGridTableSt yle, but I can't get this to
      > work with web pages.
      >
      > Any help would be appreciated.
      >
      >[/color]


      Comment

      • Eliyahu Goldin

        #4
        Re: DataGrid Column Width

        Just remember, that whatever you do in the code, meaning whatever HTML it
        produces, a browser on client's machine will consider it as a recomendation
        rather than an instruction.

        Since you can hardly be sure what width the browser will assign to your
        columns, it's not a good idea to rely on exact column width in your design.

        Eliyahu

        "Saravana" <saravank@sct.c o.in> wrote in message
        news:e$n1tR4TDH A.2196@TK2MSFTN GP12.phx.gbl...[color=blue]
        > you can programmaticall y change width of the column like this,
        >
        > datagrid1.Colum ns(0).ItemStyle .Width.Pixel(15 0)
        >
        > or
        >
        > datagrid1.Colum ns(0).ItemStyle .Width = new Unit(150,UnitTy pe.Pixel)
        >
        >
        > --
        > Saravana
        > Microsoft India Community Star,
        > MCAD,SE,SD,DBA.
        >
        >
        > "frank" <frank@frank.co m> wrote in message
        > news:#mvRZp2TDH A.2312@TK2MSFTN GP12.phx.gbl...[color=green]
        > > How do I set the column width of a column in a DataGrid programatically[/color]
        > (in[color=green]
        > > ASP.NET web pages)?
        > >
        > > I understand I may have to use DataGridTableSt yle, but I can't get this[/color][/color]
        to[color=blue][color=green]
        > > work with web pages.
        > >
        > > Any help would be appreciated.
        > >
        > >[/color]
        >
        >[/color]


        Comment

        Working...