Change control disabled state to readonly


Author
Message
dgsoft
dgsoft
StrataFrame User (135 reputation)StrataFrame User (135 reputation)StrataFrame User (135 reputation)StrataFrame User (135 reputation)StrataFrame User (135 reputation)StrataFrame User (135 reputation)StrataFrame User (135 reputation)StrataFrame User (135 reputation)StrataFrame User (135 reputation)
Group: StrataFrame Users
Posts: 93, Visits: 236
Hi,

The default behavior of controls when editable state of business object is false - controls are disabled.

When it so, I can't use shortcut menu to copy text values and so on. The question is :

Is there EASY WAY Smile to change controls behavior so controls instead disable set to readOnly.



Thank you

Denis

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.3K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Try subclassing and overriding the BindingEditable property. Inside it, set the textboxes readonly state (instead of its enabled state). I not feeling well today, but when I feel a bit better, I'll check my code....I think I've done this....
dgsoft
dgsoft
StrataFrame User (135 reputation)StrataFrame User (135 reputation)StrataFrame User (135 reputation)StrataFrame User (135 reputation)StrataFrame User (135 reputation)StrataFrame User (135 reputation)StrataFrame User (135 reputation)StrataFrame User (135 reputation)StrataFrame User (135 reputation)
Group: StrataFrame Users
Posts: 93, Visits: 236
Smile yes.. I see.. but subclassing I just don't call "easy way" to solve the problem . Smile
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
If you set the ManageUIReadonly state of the BO to false, the fields will never be automatically disabled based on the edit state. I think that this is what you are looking for. Also, you can do this on a per control basis also by setting the IgnoreUIReadonlyState property of an individual control to false.
Larry Caylor
Larry Caylor
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)
Group: Awaiting Activation
Posts: 592, Visits: 3.7K
Many of the standard Windows controls (from which the SF controls are inherited) do not have a ReadOnly property. This is one of the reasons that I use a lot of the Infragistics controls since I feel it is easier to read controls that are in ReadOnly state than controls that are disabled. I have my own version of the SF Infragistics wrapper that uses ReadOnly in place of Enabled for those controls that support it. I also modified the wrapper to set the default IgnoreManagedReadOnlyState to False instead of True so that it matches the default of the standard SF controls (not sure why they are differentWhistling ) Since the SF wrapper seldom changes and I tend to use the most recent version of the Infragistics controls, having to maintain and re-comple the code is not a problem for me. It would be nice if the standard SF Infragistics wrapper worked this way but changing it now would probably cause problems for other SF users.
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.3K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
If you just want the controls to always be enabled, then Trent's suggestion is very easy.



However, if you do want them to be unavailable until the user explicitly edits a record and just change TextBoxes to become readonly rather than disabled, so you can select text and scroll with multiline textboxes, then sub-class is a nice way to go.



yes.. I see.. but subclassing I just don't call "easy way" to solve the problem . Smile




Actually it is very easy. Here the entire class:





using MicroFour.StrataFrame.UI.Windows.Forms;

public class TextBox : Textbox, IBusinessBindable

{

  public TextBox() { }



  // This replaces the BindingEditable property of the base class with out own.

  // This changes the ReadOnly property rather than the enabled property, which

  // allows for text to be selected and for scrolling.

  public new bool IBusinessBindable.BindingEditable

  {

    get { return !this.ReadOnly; }

    set { this.ReadOnly = !value; }

  }

}




I've attached a solution. This uses the StrataFrameSample db and shows how the standard SF Textbox behaves and how a readonly one would work. It also shows another way to go, handling the EditingStateChanged event of the BO and manually setting the readonly state (not what Trent was talking about...but I was confused for a bit Blink ).



I hope one of these ways gets you going!
Attachments
TextBoxUseReadonly.zip (105 views, 19.00 KB)
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search