When you drag an UltraTextEditor control onto a form, it has a default text value, e.g. 'UltraTextEditor1'. This is undesirable, because most of the time you don't default the value of text boxes for user input, and when designing forms with many text boxes, you have to clear out the default text on each one which takes a lot of unnecessary time. I cannot find any way (e.g. through inheritance, etc.) to prevent this behavior. Is there some way to do it that I just haven't come across?
Rory,
The Text property is inherited from Control and is set by Visual Studio to the name of the instance of the control. I have attached a sample where I created a CustomControl that inherits from the UltraTextEditor and contains a "Text" property which prevents the setting of the Text property at design time. I also added a property to allow the Text property to be set at design time. You can set this property to "true' after dragging the control onto the Form so that you can set that Text property if you want to.
Open the attached application in Visual Studio 2010 and drag the CustomTextEditor from the Toolbox on to the Form. You should see that the control does not have any text in it.
If you don't want to add this "AllowDesignTimeText" property then the designer will need to be changed. This can be done but it is rather cumbersome. Take a look at the code below:
[Designer("WindowsFormsApplication2.TextEditorDesigner")]
public class TextEditor : UltraTextEditor
{
}
public class TextEditorDesigner : UltraTextEditorDesigner
public override void InitializeNewComponent(IDictionary defaultValues)
base.InitializeNewComponent(defaultValues);
ISite site = base.Component.Site;
if (site != null)
PropertyDescriptor descriptor = TypeDescriptor.GetProperties(base.Component)["Text"];
if (((descriptor != null) && (descriptor.PropertyType == typeof(string))) && (!descriptor.IsReadOnly && descriptor.IsBrowsable))
descriptor.SetValue(base.Component, String.Empty);
The designer will need to be in a different assembly because it requires a reference to Infragistics2.Win.v12.1.Design and System.Design.
Infragistics2.Win.v12.1.Design cannot be distributed.
System.Design is not part of the .NET Framework Client profile.
The Designer attribute may need to be modified to use one that also specifies the assembly.
I hope this is helpful.
Thanks both for your replies. I'm confused though -- all I'm trying to accomplish is what the built-in .net textbox (System.Windows.Forms.TextBox) already does. When you drag one onto a form, it's Text property is empty.
Support case CAS-93078-D7YVZX has been opened for you. I have submitted this issue to our development team for further review. The reference number for this item is 113676. The case will remain open and you will be updated with new information after the review. You can also send updates to the support case at any time.
You can view the status of the development issue connected to this case by going to the “My IG” tab on our website, hovering to the "My Support Activity" dropdown and selecting the "Development Issues" tab.
Please let me know if you need more information.
Thanks Mike, I appreciate it.
Hi,
You are right, of course. I never noticed that the inbox TextBox control does that.
You asked if there was any way you could change this and there really isn't any reasonable way to do it. Yes, you could use Michael's suggestion about deriving your own class from UltraTextEditor and also a designer class. But that seems like overkill to me. It would probably be simpler to skip the designer class and clear the text on OnCreateControl. But even that seems like overkill to me.
Since the inbox TextBox text starts off blank, I think we should consider this a bug in UltraTextEditor and get it fixed. I will ask Infragistics Developer Support to create a case for you (if they haven't already) and write this up for developer review.