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; }
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; } }
I have the same problem. I tried your solution and it does work, however -- I want the two bands to have synchronized sizing. This is disabled by the ResizeAllColumns you are doing which appears to fix the issue. If I try to manually add that feature in InitializeLayout with...
e.Layout.Override.AllowColSizing = Infragistics.Win.UltraWinGrid.AllowColSizing.Synchronized;
It goes back to one super wide first column that cannot be resized. What gives?
I figured out my problem. I am binding to a list of custom objects. Each has a "children" collection of the same type of object. So, potentially, this is an endlessly deep well, even though in my code I was limiting this to two levels.
I changed my classes so that the only the top-level object had the nested collection and the child objects didn't and the problems go away.
This also seems to be real issue in the original post. The solution offered dodges the issue, but the real problem is that the grid is being bound to a list of objects which in turn have a list of embedded objects of the same type. The grid seems to choke on the potential infinite depth even if the actual data has a fixed depth.
Hi Mebstein,
I am facing the same problem as you had faced. I am also using list of custom objects. And after binding, the first column of the grid is becoming too wide.
You have mentioned that in your post you have changed your classes to resolve the problem. Kindly provide more information along with some sample code as how to change the hierarchical implementation of list of custom objects. It would help me to resolve the issue.
I have also attached the sample code of the custom list objects that I am using to bind the grid. Please have a look at it.
Your help in this would be greatly appreciated.
Thanks,
Amit
My solution was very simple -- I created wrapper objects that concealed the potential infinite depth and then bound to the wrappers.
Imagine my class was called Node with a property called Child of type Node. Binding to a list of these would create the issue since each Node could have more Nodes and they could have more Nodes... forever.
My solution was to create a new object model with only the depth I intended. Imagine two new classes: Parent and Child. Each has a private member of type Node. The Parent class exposes the Child property of its contained Node, but the Child class does not. I bind to a list of Parent objects. Thus, the infinite regression stops at the Child.
Not too sophisticated I'm afraid, but it got the job done!