Ticket T368884
Visible to All Users

WinForms - How to customize ActionContainerViewItem's Action height and width

created 9 years ago

Hi DevExpress,

I have previously followed the following documentation to add an action button to a detail view (https://documentation.devexpress.com/#eXpressAppFramework/CustomDocument112816), i wish to increase the size of the action within the detail view however so far i have been unable to achieve this.

Many thanks,

Carl

Answers approved by DevExpress Support

created 9 years ago (modified 6 years ago)

Hello Carl,

You can accomplish this task using one of the following approaches:
1.  In versions 16.2+, handle the ActionBase.CustomizeControl event of the required action and set the MinimumSize property of the action's control:

C#
using DevExpress.ExpressApp; using DevExpress.ExpressApp.Actions; using DevExpress.XtraEditors; namespace MainDemo.Module.Win { public class ViewController1 : ViewController<DetailView> { public ViewController1() { SimpleAction action = new SimpleAction(this, "MyAction12", "DetailViewActions"); action.CustomizeControl += Action_CustomizeControl; } private void Action_CustomizeControl(object sender, CustomizeControlEventArgs e) { SimpleButton button = e.Control as SimpleButton; if (button != null) { button.MinimumSize = new System.Drawing.Size(500, 0); } } } }

2. Define size constraints for the corresponding layout item. I have attached a video (video.swf) demonstrating how to do this in the Model Editor. Refer to the Custom Size Constraints topic for additional information.

3. Change the width of the underlying controls. Here is an example of how to change the width of the entire buttons control in WinForms:

C#
using DevExpress.ExpressApp.Editors; using DevExpress.ExpressApp.Win.Templates.ActionContainers; public class ViewController1 : ViewController<DetailView> { protected override void OnActivated() { base.OnActivated(); foreach (WinActionContainerViewItem actionContainer in View.GetItems<WinActionContainerViewItem>()) { actionContainer.ControlCreated += actionContainer_ControlCreated; } } void actionContainer_ControlCreated(object sender, EventArgs e) { ((ButtonsContainer)((WinActionContainerViewItem)sender).Control).MinimumSize = new System.Drawing.Size(500, 0); } protected override void OnDeactivated() { base.OnDeactivated(); foreach (WinActionContainerViewItem actionContainer in View.GetItems<WinActionContainerViewItem>()) { actionContainer.ControlCreated -= actionContainer_ControlCreated; } } }

In addition, see how to change the width of individual buttons here: Customize ButtonSize for ActionViewController in DetailView. Refer to the Access Editor Settings topic for additional information.

If you need to increase the size of buttons shown in the PopupActions action container (e.g. OK and Cancel), you can customize the ButtonsContainer control returned by the PopupForm.ButtonsContainer property. Here is an example:

C#
using DevExpress.ExpressApp.Win.Templates.ActionContainers; using DevExpress.ExpressApp.Win.Templates; public partial class ViewController1 : ViewController { public ViewController1() { PopupWindowShowAction action = new PopupWindowShowAction(this, "ShowPopup", DevExpress.Persistent.Base.PredefinedCategory.View); action.CustomizePopupWindowParams += action_CustomizePopupWindowParams; action.CustomizeTemplate += action_CustomizeTemplate; } void action_CustomizeTemplate(object sender, CustomizeTemplateEventArgs e) { if (e.Template is PopupForm) { ButtonsContainer popupActions = ((PopupForm)e.Template).ButtonsContainer; foreach (KeyValuePair<ActionBase, ButtonsContainersActionItemBase> item in popupActions.ActionItems) { if (item.Key.Id == "DialogOK" || item.Key.Id == "DialogCancel") { item.Value.Control.MinimumSize = new Size(200, 0); } } } } void action_CustomizePopupWindowParams(object sender, CustomizePopupWindowParamsEventArgs e) { IObjectSpace os = Application.CreateObjectSpace(typeof(DemoTask)); e.View = Application.CreateDetailView(os, os.CreateObject<DemoTask>()); } }

See Also
Web - How to customize ActionContainerViewItem's Action height and width

    Comments (2)
    CH CH
    Carl Howarth 1 9 years ago

      Thanks Anatol,

      That looks like it is going to work exactly as expected!

      Many thanks,

      Carl

      Anatol (DevExpress) 9 years ago

        You are welcome!

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.