I have extended a ultratextbox and I like to set the control hieght to a specific height (21) when the control is created in design mode. I found an article on msdn to how to perform custom initialization for controls in design mode by overriding the InitializeNewComponent method. Is there a way to do this with the infragistics controls?
John
If I remember correctly, InitializeNewComponent is on the designer class itself and not the control. If you only ever want this to be applicable when the control is created at design-time, then I think you'd have to create your own class that derives from the UltraTextEditor's designer (UltraTextEditorDesigner) and override the InitializeNewComponent. Then you'd have to add the Designer attribute to a new derived class that you would need to create for the control itself.
If you want this to be applicable to any controls created at run-time too (or just don't care because you're not creating anything at run-time), I would think that the much simpler approach would be to override the DefaultSize property on the control.
-Matt
Matt
Do you have some sample code on how to do this?
john
My guess is that it's because you're using the wrong designer for your control; you are using the UltraComboEditor's designer, not the UltraCombo's designer. If you want the combo's designer, it's in the Infragistics2.Win.Design assembly, I believe, and has a fully qualified name of "Infragistics.Win.UltraWinGrid.Design.UltraComboDesigner".
Matt,
Thanks for you help the code sample you gave me worked great for the textbox. I tried to apply the same code to the combobox and i get an error on the following item.
base.InitializeNewComponent(defaultValues);
System.NullReferenceException: Object reference not set to an instance of an object.at Infragistics.Win.UltraWinEditors.UltraComboEditorDesigner.UltraComboEditorActionList.CreateActionItems(DesignerActionItemCollection actionItems)at Infragistics.Win.Design.UltraActionListBase`1.GetSortedActionItems()at System.ComponentModel.Design.DesignerActionService.GetComponentDesignerActions(IComponent component, DesignerActionListCollection actionLists)at System.ComponentModel.Design.DesignerActionService.GetComponentActions(IComponent component, ComponentActionsType type)at System.ComponentModel.Design.DesignerActionUIService.ShouldAutoShow(IComponent component)at System.ComponentModel.Design.ComponentDesigner.InitializeNewComponent(IDictionary defaultValues)at System.Windows.Forms.Design.ControlDesigner.InitializeNewComponent(IDictionary defaultValues)at ClassLibrary5.MyComboBoxDesigner.InitializeNewComponent(IDictionary defaultValues) in c:\\Testing\\ClassLibrary5\\ClassLibrary5\\UserControl1.cs:line 27"
{
[Designer(typeof(MyComboBoxDesigner))]
public partial class mycombo : Infragistics.Win.UltraWinGrid.UltraCombo
InitializeComponent();
}
public class MyComboBoxDesigner : Infragistics.Win.UltraWinEditors.UltraComboEditorDesigner
//error happens here
mycombo editor = this.Control as mycombo;
editor.Height = 21;
John,
Something like the following should work:
[Designer(typeof(MyDesigner))]public class MyTextEditor : UltraTextEditor{}public class MyDesigner : UltraTextEditorDesigner{ public override void InitializeNewComponent(System.Collections.IDictionary defaultValues) { base.InitializeNewComponent(defaultValues); MyTextEditor editor = this.Control as MyTextEditor; if (editor != null) { editor.Multiline = true; editor.Size = new Size(this.Control.Width, 40); } }}