Skip to content

Infragistics Community Forum / Cross Platform / Ultimate UI for Xamarin / Changing the Column Width from code behind

Changing the Column Width from code behind

New Discussion
Rajiv
Rajiv asked on Sep 26, 2016 9:13 AM

Hi,

I have a requirement where I need to set the width of a column to "Auto". I am able to do this from XAML code but couldn't find a way to set it from code behind.

Though, I am aware that to change the width I can use – column.Width = new ColumnWidth(3.5, true);

but with this approach I am not sure if the width can be set to "Auto".

Any suggestions on this is appreciated.

Thank You,

Raj

Sign In to post a reply

Replies

  • 0
    [Infragistics]Tacho
    [Infragistics]Tacho answered on Sep 21, 2016 8:46 AM

    Hello Raj,

    In order to set the width of a column in XamGrid to Auto in code-behind, you can set the Width property of the respective column to ColumnWidthType.InitialAuto or ColumnWidthType.Auto.

    Code-behind:

    xamGrid.ColumnWidth = ColumnWidthType.InitialAuto;

    For more detailed information, you can take a look at Change Column Width Settings.

    If you require any further assistance on the matter, please let me know.

    • 0
      Rajiv
      Rajiv answered on Sep 21, 2016 9:09 AM

      Hi Tacho,

      The ColumnWidth property mentioned above is available at the XAMGrid level and I don't see it at the column level. My requirement is to set the width of specific column(s) to "Auto".


      Thanks,

      Raj

      • 0
        [Infragistics]Tacho
        [Infragistics]Tacho answered on Sep 21, 2016 11:27 AM

        Hello Raj,

        Setting a specific width to any of the Columns can be done by casting the column to it's actual type and setting it's Width property respectively.

        For example:

        (grid.Columns[0] as TextColumn).Width = ColumnWidth.Star;

        (grid.Columns[1] as TextColumn).Width = ColumnWidth.Auto;

        (grid.Columns[2] as TextColumn).Width = new ColumnWidth(60, false);

        If you require any further assistance on the matter, please let me know.

         

      • 0
        Rajiv
        Rajiv answered on Sep 21, 2016 5:02 PM

        Thank You, Tacho. Worked for me.

      • 0
        [Infragistics]Tacho
        [Infragistics]Tacho answered on Sep 26, 2016 9:13 AM

        Hello Raj,

         

        Thank you for your feedback.

        I am glad to know that I was able to help you achieve the functionality you were looking for. I believe this thread can help other people looking for a similar solution.

         

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Rajiv
Favorites
0
Replies
5
Created On
Sep 26, 2016
Last Post
9 years, 6 months ago

Suggested Discussions

Tags

Created by

Created on

Sep 26, 2016 9:13 AM

Last activity on

Sep 26, 2016 9:13 AM