Ticket Q397317
Visible to All Users
Duplicate

We have closed this ticket because another page addresses its subject:

Change font size of a property in (Web) DetailView

Change font and caption for editors in detail view on the Web

created 13 years ago

I want to change font for some editors in detail view and tryed Q281859, but CaptionControl and LayoutItemControl of container is null.

Comments (2)
Dennis Garavsky (DevExpress) 13 years ago

    Hello Roman,
    It looks like the standard approach described at Access Editor Settings is the best to accomplish your task. You can find some examples of it at Change font size of a property in (Web) DetailView.
    Alternatively, you can perform the required customizations via CSS. Refer to the next two tickets for more details:
    How can i change default font in web application?
    UI.Web: Layout Group Caption Formatting in Detail Views
    I hope this helps.
    Thanks,
    Dennis
    News, tips & tricks and other interesting information about DevExpress Application Framework and ORM

    RS RS
    Roman Shelomanov 13 years ago

      Yes, this works in edit mode, but:

      1. (editor as DevExpress.ExpressApp.Web.Editors.ASPx.ASPxStringPropertyEditor).FontStyle
        '…does not contain definition for FontStyle'
      2. In View mode (editor as DevExpress.ExpressApp.Web.Editors.ASPx.ASPxStringPropertyEditor).Editor is null (Under debug editor.Editor is null, independent of type)

      Answers approved by DevExpress Support

      created 13 years ago (modified 12 years ago)

      Hello Roman,
      Please try the following modification of the MainDemo.Web controller:

      C#
      using System; using System.Drawing; using DevExpress.ExpressApp; using DevExpress.Web.ASPxEditors; using System.Collections.Generic; using DevExpress.ExpressApp.Utils; using DevExpress.ExpressApp.Web.Editors; namespace MainDemo.Module.Web.Controllers { public partial class WebNullTextEditorController : ViewController { public WebNullTextEditorController() { InitializeComponent(); RegisterActions(components); } private void InitNullText(WebPropertyEditor propertyEditor) { Control c = (Control)propertyEditor.Control; if(c != null) c.Load += delegate(object s, EventArgs args) { if(propertyEditor.ViewEditMode == DevExpress.ExpressApp.Editors.ViewEditMode.Edit) { ASPxComboBox editor = propertyEditor.Editor as ASPxComboBox; if(editor != null) ChangeStyle(editor); //Dennis: Changing the editor's style. } if(propertyEditor.ViewEditMode == ViewEditMode.View) { Label label = propertyEditor.InplaceViewModeEditor as Label; if(label != null) ChangeStyle(label); ASPxImageLabelControl imageLabel = propertyEditor.InplaceViewModeEditor as ASPxImageLabelControl; if(imageLabel != null) ChangeStyle(imageLabel.Label); //Dennis: Changing the editor's style. } ChangeStyle(c.Parent.Parent.Controls[0] as WebControl); //Dennis: Changing the label's style. }; } private void WebNullTextEditorController_Activated(object sender, EventArgs e) { WebPropertyEditor propertyEditor = ((DetailView)View).FindItem("TitleOfCourtesy") as WebPropertyEditor; if(propertyEditor != null) { if(propertyEditor.Control != null) { InitNullText(propertyEditor); } else { propertyEditor.ControlCreated += new EventHandler<EventArgs>(propertyEditor_ControlCreated); } } } private void propertyEditor_ControlCreated(object sender, EventArgs e) { InitNullText((WebPropertyEditor)sender); } } }

      Does it work for you?
      Thanks,
      Dennis

        Show previous comments (7)
        RS RS
        Roman Shelomanov 13 years ago

          Hello, Dennis.
          Thanks for your answer, but I have tryed this suggestion above:
          >>Then I tryed "Highlight required field in detailview", but e.TemplateContainer.Controls.Count always equal zero.
          >>Next, I have tryed modification for editors and it partially works, thanks! But it doesn't works when I use enum type field in view mode.
           propertyEditor.InplaceViewModeEditor have DevExpress.ExpressApp.Web.Controls.ASPxImageLabelControl type.
           I tryed:
          if (propertyEditor.InplaceViewModeEditor is System.Web.UI.WebControls.Label )
                               ChangeStyle((System.Web.UI.WebControls.Label)propertyEditor.InplaceViewModeEditor);
                           else if (propertyEditor.InplaceViewModeEditor is DevExpress.ExpressApp.Web.Controls.ASPxImageLabelControl)
                               ChangeStyle((DevExpress.ExpressApp.Web.Controls.ASPxImageLabelControl)propertyEditor.InplaceViewModeEditor);
          but unsuccessfully.
          Totally, I want know how can I change FontSize and other appearance for caption and for enum editor in view mode.

          Dennis Garavsky (DevExpress) 13 years ago

            Hello Roman,
            >>
            >>changing the caption style is a little bit more complex (because you will need to locate a required table cell and its controls), but still possible. Refer to the Highlight required field in detailview ticket for more information.
            Your goal is to locate the caption control within the table hierarchy (cells and rows) starting from the editor's control and referring to higher levels by the Parent property.
            <<
            The code below demonstrates the solution I was talking about above:

            C#
            private void InitNullText(WebPropertyEditor propertyEditor) { Control c = (Control)propertyEditor.Control; if(c != null) c.Load += delegate(object s, EventArgs args) { if(propertyEditor.ViewEditMode == DevExpress.ExpressApp.Editors.ViewEditMode.Edit) { ASPxComboBox editor = propertyEditor.Editor as ASPxComboBox; if(editor != null) ChangeStyle(editor); //Dennis: Changing the editor's style. } if(propertyEditor.ViewEditMode == ViewEditMode.View) { Label label = propertyEditor.InplaceViewModeEditor as Label; if(label != null) ChangeStyle(label); ASPxImageLabelControl imageLabel = propertyEditor.InplaceViewModeEditor as ASPxImageLabelControl; if(imageLabel != null) ChangeStyle(imageLabel.Label); //Dennis: Changing the editor's style. } ChangeStyle(c.Parent.Parent.Controls[0] as WebControl); //Dennis: Changing the label's style. }; } private void WebNullTextEditorController_Activated(object sender, EventArgs e) { WebPropertyEditor propertyEditor = ((DetailView)View).FindItem("TitleOfCourtesy") as WebPropertyEditor; if(propertyEditor != null) { if(propertyEditor.Control != null) { InitNullText(propertyEditor); } else { propertyEditor.ControlCreated += new EventHandler<EventArgs>(propertyEditor_ControlCreated); } } }

            Thanks,
            Dennis

            RS RS
            Roman Shelomanov 13 years ago

              Thanks, Dennis, this works!

              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.