Hi there,
I'm looking to use this snippet: http://help.infragistics.com/Help/NetAdvantage/NET/2007.2/CLR2.0/html/Infragistics2.Win.Misc.v7.2~Infragistics.Win.Misc.UltraExpandableGroupBox.html
But i've got a problem because my UltraExpandableGroupBox is code generated. I'm looking after the Panel attribute ut this one is null.
UltraExpandableGroupBox uegb = new UltraExpandableGroupBox();uegb.Panel.Controls.Add(myControl);
And so I've a NullReferenceException.
I tried this too:
UltraExpandableGroupBox uegb = new UltraExpandableGroupBox();UltraExpandableGroupBoxPanel panel = new UltraExpandableGroupBoxPanel();uegb.Panel = panel;
But I got this compilation error: Property or indexer 'Infragistics.Win.Misc.UltraExpandableGroupBox.Panel' cannot be assigned to -- it is read only
Please help!
The UltraExpandableGroupBox will not create its panel until it gets the OnCreateControl method called; this behavior was originally implemented due to the fact that the panel cannot be created when the control is during at design-time due to the registration process and some issues that arose then.
There is a protected virtual method that was implemented for the case that you are currently stuck at. What you should do is derive your own class from UltraExpandableGroupBox and override the OnPanelInitialized method, where you can then add your controls to the panel.
-Matt
Hi Matt and thanks for your answer.
Should I do like that?
class CustomUltraExpandableGroupBox : UltraExpandableGroupBox{ protected override void OnPanelInitialized() { base.OnPanelInitialized(); //Ajout du panel this.Panel = new UltraExpandableGroupBoxPanel(); }}
I got the same problem anymore...
Sorry for the confusion. This method is called when the UltraExpandableGroupBox creates its panel; you cannot assign your own panel to this property. So, now that you have the panel in this method, you can simply do "this.Panel.Controls.Add(myControl);".
Hi have a similar problem. When I create the group box at run time and then try and add another control into it the Panel property is always null. I am using NetAdvantage for .NET 2007 Volume 1 CLR 1.x. When I create the class above that inherits the expandable group box I do not have visibility to OnPanelInitialized(). Is there another event that I can override or listen to in order to then populate the controls into the panel?
thanks in advance
I think that you're misunderstanding the point of the OnPanelInitialized method. You will never be able to assign anything to the Panel property, this is created by the UltraExpandableGroupBox. You need to use the OnPanelInitialize method to populate the contents of your control, such as:
public partial class Form1 : Form{ public Form1() { InitializeComponent(); MyExGroupBox grp = new MyExGroupBox(); grp.Dock = DockStyle.Fill; this.Controls.Add(grp); } private class MyExGroupBox : UltraExpandableGroupBox { protected override void OnPanelInitialized() { base.OnPanelInitialized(); Label label = new Label(); label.BackColor = Color.Blue; label.Dock = DockStyle.Fill; this.Panel.Controls.Add(label); } }}
No problem ;)
But there's still a problem.
Your method is the first I tried, but the property .Panel is null when i do a [UltraExpandableGroupBox uegb = new UltraExpandableGroupBox();]
So I can't access the .Controls attribute and no more the .Add() method...
[EDIT] If I modify the Panel attribute even in the class Custom, I've got: Property or indexer (...) cannot be assigned to -- it is read only