Hello,
I have to create dynamically several UltraExpandableGroupBox. All of them are inserted into a .NET FlowLayoutPanel just after been created.My FlowLayoutPanel is docked in my form and I want my UltraExpandableGroupBox resize automatically (specially the Horizontal size) into the FlowLayoutPanel when the user change the form size. Unfortunatly, my UltraExpandableGroupBox never resize even when the FlowLayoutPanel resize itself.Here is a sample of my code. Thanks if anyone can help me to find out what to do.
UltraExpandableGroupBox uegb = new UltraExpandableGroupBox(); UltraExpandableGroupBoxPanel panel = new UltraExpandableGroupBoxPanel(); MyUsercontrol uc = new MyUsercontrol();
((ISupportInitialize)uegb).BeginInit(); uegb.SuspendLayout(); panel.SuspendLayout();
uc.Presenter = _presenter; uc.Dock = DockStyle.Top; uc.BuildAndBindFields(container, regroupement); // build MyUserconrol content.
// box
uegb.Controls.Add(panel); uegb.Dock = DockStyle.Top; uegb.MinimumSize = new System.Drawing.Size(685, 24); uegb.ExpandedSize = new System.Drawing.Size(685, 500); uegb.ExpansionIndicator = Infragistics.Win.Misc.GroupBoxExpansionIndicator.Far; uegb.Location = new System.Drawing.Point(3, 3); uegb.Text = container.GetTraduction(regroupement); uegb.ViewStyle = Infragistics.Win.Misc.GroupBoxViewStyle.Office2003; uegb.Expanded = false;
// panel
panel.Controls.Add(uc); panel.AutoScroll = true; panel.Dock = System.Windows.Forms.DockStyle.Fill; panel.Location = new System.Drawing.Point(2, 22); panel.Size = new System.Drawing.Size(681, 426);
((ISupportInitialize)(uegb)).EndInit(); panel.ResumeLayout(false); uegb.ResumeLayout(false);
Is this a bug? I am unable to get my controls to resize inside a flow layout panel as well.
I was able to get the UltraGroupBox to "AutoSize", but it was a hack.
private void BuildMyControl(){ UltraGroupBox ugb = new UltraGroupBox(); ugb.Dock = DockStyle.Top; this.Controls.Add(ugb); ugb.Text = "My Control"; Panel pnl = new Panel(); pnl.AutoSize = true; pnl.Dock = DockStyle.Top; pnl.Top = 21; // Make room for the header ugb.Controls.Add(pnl); //... // Add whatever controls you want to the Panel, not the GroupBox //... ugb.Height = pnl.Top + pnl.Height;}
It got the job done for me... I would like to know of a fix for this, though...
Thanks Matt...
I've only been using the Infragistics controls for a month now and was sorta thown into the fire with them. Basically, I was trying to get the UltraGroupBox to AutoSize (vertically in my case) to the size needed to display its child controls. Like the built in "Panel" does... Or like an HTML TableCell does.
Am I using the wrong control for this?
-D
I wouldn't say you're using the wrong control, just that the GroupBox doesn't support this auto-size functionality. I'm not sure why it wasn't implemented, since the .NET GroupBox supports AutoSize; however, the more people that submit a feature request, the more likely it will be implemented in a future release.
This being said, I don't really see a problem with your approach; you're using a different control's existing AutoSize functionality, then just adjusting the height of the GroupBox accordingly.
-Matt
If look at UltraExpandableGroupBox using the Mole visualizer, it shows an AutoSize property which can be set True giving desired results. Why isnt this property exposed to the property grid? And how can I use reflection to get to it programatically? (Mole is existence-proof)
The AutoSize property is provided by the base Control class; in CLR2 the AutoSize property was added to Control, but this property defaults to False and is not browsable, since many controls written prior to CLR2 do not support this property.
With this being said, it seems that there was a bug fix made last August for a (seemingly) unrelated issue that has now enabled the AutoSize property to work for the UltraExpandableGroupBox (but not the UltraGroupBox). The property is only prevented from showing up in the PropertyGrid or with Intellisense, but you can still explicitly type in the code:
this.ultraExpandableGroupBox1.AutoSize = true;
I should note that there really hasn't been any extensive testing on this, since the property isn't officially supported, but it seemed to work in my quick test project.
Matt!
That is a full on awesome workaround it's made my morning!
Thanks! Tom