我有UserControl'A'带有标签,这个属性:
/// <summary>
/// Gets or Sets the text of the control
/// </summary>
[
Browsable(true),
EditorBrowsable(EditorBrowsableState.Always),
Category("Appearance")
]
public override string Text {
get {
return uxLabel.Text;
}
set {
uxLabel.Text = value;
}
}
Run Code Online (Sandbox Code Playgroud)
然后我有UserControl'B',其上有UserControl'A',我在设计器中将Text Property设置为"My Example Label".然后,我有我的MainForm,它上面有UserControl'B'.
每次进行构建或运行时,UserControl的"A"的Text属性都会重置为其默认值.我想这是因为我正在进行重建,它会重建UserControl'A'和'B',从而导致问题.
在应用程序中使用紧密绑定的控件和表单时,如何更好地设计模式以避免此类行为?
我在某处读到某人可以在运行时访问配置值,但在设计时不能访问.在这种情况下,运行时间和设计时间之间的区别是什么?
我有一个自定义控件,其中包含 6 个面板控件,它们的作用类似于在设计时放入的其他控件的容器。这是通过创建一个继承自 ParentControlDesign 的自定义设计器来完成的。在设计器中,我使用 EnableDesignMode 为每个面板控件启用设计时功能。问题是当我使用控件时,我可以移动面板。我可以做些什么来防止它们在设计时移动?
我在我的自定义控件中添加了一个新属性作为可扩展属性,如Property Grid中的font属性.在Windows窗体应用程序项目中使用自定义控件后,我在属性网格中看到了类似"..."按钮的省略号(...)按钮.(有关详细信息,请参阅下图.)

现在,我想隐藏我的新可扩展属性的省略号(...)按钮.
可扩展的属性代码是:
[DisplayName("Floors Information")]
[Description("Floors Informationnnnnnnnnnnnnnnn")]
[DefaultProperty("TitleText")]
[DesignerCategory("Component")]
public class FloorsInformation : DockContainerItem
{
private SimilarFloorsInformation similarFloorsInformation = new SimilarFloorsInformation();
public FloorsInformation()
{
}
[Category("Data")]
[DisplayName("Similar Floors Panel")]
[Description("Similar Floors Panellllllllllllllllllll")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[Editor(typeof(ItemsCollectionEditor), typeof(UITypeEditor))]
//[TypeConverter(typeof(ExpandableObjectConverter))]
//[TypeConverter(typeof(SimilarFloorsInformationTypeConverter))]
public SimilarFloorsInformation SimilarFloorsInfo
{
get
{
return similarFloorsInformation;
}
}
}
[DisplayName("Similar Floors Information")]
[Description("Similar Floors Informationnnnnnnnnnnnnnnn")]
[DefaultProperty("Text")]
[DesignerCategory("Component")]
[TypeConverter(typeof(SimilarFloorsInformationTypeConverter))]
//[TypeConverter(typeof(ExpandableObjectConverter))]
public class SimilarFloorsInformation : ExpandablePanel
{
private Color canvasColor = SystemColors.Control;
private eCollapseDirection collapseDirection = eCollapseDirection.LeftToRight;
private eDotNetBarStyle colorSchemeStyle = eDotNetBarStyle.StyleManagerControlled; …Run Code Online (Sandbox Code Playgroud) 我定义了一个自定义按钮类,它在启用/禁用按钮时设置背景颜色.
在运行时启用外观(A):

运行时禁用外观(B):

无论Enabled属性值如何,设计时外观始终为(A).
我希望我的控件能够完全按照运行时出现的方式出现在设计器中.是否有可能,如果是这样,怎么办呢?
这是我尝试过的(只是代码的相关部分):
Public Class StyledButton : Inherits Button
Private p_fEnabled As Boolean
<DefaultValue(True)>
Public Shadows Property Enabled As Boolean
Get
Return p_fEnabled
End Get
Set(value As Boolean)
p_fEnabled = value
MyBase.Enabled = value
UpdateVisualStyle()
End Set
End Property
Private Sub UpdateVisualStyle()
If Me.Enabled Then
'set enabled appearance
Else
'set disabled appearance
End If
End Sub
End Class
Run Code Online (Sandbox Code Playgroud) 设计时和运行时框架之间有什么区别,如"Oracle ADF是Java EE设计时和运行时框架"?
我有一个可以在运行时或设计时创建的表单来帮助组件.但是,我需要知道这个表单是在设计还是运行时打开,有人知道怎么做吗?
我正在开发一些组件 - 自定义按钮。我安装了它,但在设计时自定义发布的属性重置为零。首先,我在谈论颜色 - 它重置为clBlack(或clBtnFace用于Color财产)。Caption重置为空字符串。我的意思是当我在设计时放置组件以形成表单时,对象检查器中的所有自定义属性都重置为零(颜色clBlack等)。我可以手动更改它,但为什么我在代码中设置的默认值不起作用?问题仅在设计时。当我在运行时创建组件时,它工作正常。这是代码(以Color属性为例)。
基类
TpfCustomButton = class(TCustomControl)
...
published
...
property Color;
...
end;
Run Code Online (Sandbox Code Playgroud)
主要代码
TpfCustomColoredButton = class(TpfCustomButton)
...
public
constructor Create(AOwner: TComponent);
...
end;
constructor TpfCustomColoredButton.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Color := $00E1E1E1;//Look at this: setting Color
...
end;
Run Code Online (Sandbox Code Playgroud)
组件代码
TpfColoredButton = class(TpfCustomColoredButton)
published
...
property Action;
property Align;
//And some other standard properties
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('PF Components', [TpfColoredButton]);
end; …Run Code Online (Sandbox Code Playgroud) 我的Delphi组件如何在设计时检测是否有任何其他组件被丢弃在表单上?
design-time ×9
c# ×3
components ×3
delphi ×3
runtime ×3
winforms ×2
appearance ×1
architecture ×1
button ×1
containers ×1
delphi-xe2 ×1
forms ×1
frameworks ×1
properties ×1
propertygrid ×1
vb.net ×1