I want to change font for some editors in detail view and tryed Q281859, but CaptionControl and LayoutItemControl of container is null.
We have closed this ticket because another page addresses its subject:
Change font size of a property in (Web) DetailViewChange font and caption for editors in detail view on the Web
Answers approved by DevExpress Support
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
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.
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
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
Yes, this works in edit mode, but:
'…does not contain definition for FontStyle'