Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
425
Problem with column width after setting hierarchical binding list
posted

Normal 0 21 false false false DE X-NONE X-NONE MicrosoftInternetExplorer4

Hello,

 

I am setting a hierarchical binding list as data source to my grid. After data binding, the first column cannot be resized. See my following code and screen hot. The problem is the sub binding list. Without the sub binding list all works fine. Setting the column width was ignored from the grid.

 

        public Form1()

        {

            InitializeComponent();

 

            ultraGrid1.DisplayLayout.AutoFitStyle = Infragistics.Win.UltraWinGrid.AutoFitStyle.None;

            ultraGrid1.DisplayLayout.Override.CellClickAction = Infragistics.Win.UltraWinGrid.CellClickAction.RowSelect;

            BindingList<DocumentInfo> documentInfoList = new BindingList<DocumentInfo>();

            DocumentInfo documentInfo = new DocumentInfo();

            documentInfo.Identifier = "123";

            documentInfo.Name = "First";

            documentInfoList.Add(documentInfo);

            ultraGrid1.DataSource = documentInfoList;

            ultraGrid1.DataBind();

ultraGrid1.DisplayLayout.Bands[0].Columns["Identifier"].Width = 200;

        }

 

        private class DocumentInfo

        {

            private string mIdentifier;

            public string Identifier

            {

                get { return mIdentifier; }

                set { mIdentifier = value; }

            }

 

            private string mName;

            public string Name

            {

                get { return mName; }

                set { mName = value; }

            }

 

            private BindingList<DocumentInfo> mSubDocumentList;

            public BindingList<DocumentInfo> SubDocumentList

            {

                get { return mSubDocumentList; }

                set { mSubDocumentList = value; }

            }

        }

 


 

Parents
No Data
Reply
  • 12333
    posted

    Hi,

    I made the following changes to your code and I am able to change the size programmatically. When I comment the code in the InitializeLayout event, I am also able to manually resize the column:

     

            private void Form1_Load(object sender, EventArgs e)
            {
                //ultraGrid1.DisplayLayout.AutoFitStyle = Infragistics.Win.UltraWinGrid.AutoFitStyle.None;

                ultraGrid1.DisplayLayout.Override.CellClickAction = Infragistics.Win.UltraWinGrid.CellClickAction.RowSelect;

                BindingList<DocumentInfo> documentInfoList = new BindingList<DocumentInfo>();

                DocumentInfo documentInfo = new DocumentInfo();

                documentInfo.Identifier = "123";

                documentInfo.Name = "First";

                documentInfoList.Add(documentInfo);

                ultraGrid1.DataSource = documentInfoList;

                //ultraGrid1.DataBind();

                //ultraGrid1.DisplayLayout.Bands[0].Columns["Identifier"].Width = 200;

              
            }

            private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
            {
                e.Layout.AutoFitStyle = Infragistics.Win.UltraWinGrid.AutoFitStyle.ResizeAllColumns;

                e.Layout.Bands[0].Columns["Identifier"].MinWidth = 100;
                e.Layout.Bands[0].Columns["Identifier"].MaxWidth = 100;
                e.Layout.Bands[0].Columns["Identifier"].Width = 100;
            }
        }

Children