* UITextBox:修改文字可以居中显示

This commit is contained in:
Sunny 2021-04-15 17:43:13 +08:00
parent 66735ac0f5
commit 7571edbb7c
8 changed files with 11 additions and 8 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -80,6 +80,7 @@
this.uiIntegerUpDown1.Size = new System.Drawing.Size(150, 29); this.uiIntegerUpDown1.Size = new System.Drawing.Size(150, 29);
this.uiIntegerUpDown1.TabIndex = 2; this.uiIntegerUpDown1.TabIndex = 2;
this.uiIntegerUpDown1.Text = "_uiIntegerUpDown1"; this.uiIntegerUpDown1.Text = "_uiIntegerUpDown1";
this.uiIntegerUpDown1.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
// //
// uiTextBox1 // uiTextBox1
// //
@ -95,6 +96,7 @@
this.uiTextBox1.Padding = new System.Windows.Forms.Padding(5); this.uiTextBox1.Padding = new System.Windows.Forms.Padding(5);
this.uiTextBox1.Size = new System.Drawing.Size(221, 29); this.uiTextBox1.Size = new System.Drawing.Size(221, 29);
this.uiTextBox1.TabIndex = 3; this.uiTextBox1.TabIndex = 3;
this.uiTextBox1.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
this.uiTextBox1.Watermark = "水印文字"; this.uiTextBox1.Watermark = "水印文字";
// //
// uiLabel1 // uiLabel1
@ -137,6 +139,7 @@
this.uiTextBox2.Size = new System.Drawing.Size(221, 29); this.uiTextBox2.Size = new System.Drawing.Size(221, 29);
this.uiTextBox2.TabIndex = 5; this.uiTextBox2.TabIndex = 5;
this.uiTextBox2.Text = "5"; this.uiTextBox2.Text = "5";
this.uiTextBox2.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
this.uiTextBox2.Type = Sunny.UI.UITextBox.UIEditType.Integer; this.uiTextBox2.Type = Sunny.UI.UITextBox.UIEditType.Integer;
this.uiTextBox2.Watermark = "水印文字"; this.uiTextBox2.Watermark = "水印文字";
// //
@ -166,6 +169,7 @@
this.uiTextBox3.Padding = new System.Windows.Forms.Padding(5); this.uiTextBox3.Padding = new System.Windows.Forms.Padding(5);
this.uiTextBox3.Size = new System.Drawing.Size(221, 29); this.uiTextBox3.Size = new System.Drawing.Size(221, 29);
this.uiTextBox3.TabIndex = 7; this.uiTextBox3.TabIndex = 7;
this.uiTextBox3.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
this.uiTextBox3.Type = Sunny.UI.UITextBox.UIEditType.Double; this.uiTextBox3.Type = Sunny.UI.UITextBox.UIEditType.Double;
this.uiTextBox3.Watermark = "水印文字"; this.uiTextBox3.Watermark = "水印文字";
// //
@ -179,6 +183,7 @@
this.uiDoubleUpDown1.Size = new System.Drawing.Size(150, 29); this.uiDoubleUpDown1.Size = new System.Drawing.Size(150, 29);
this.uiDoubleUpDown1.TabIndex = 14; this.uiDoubleUpDown1.TabIndex = 14;
this.uiDoubleUpDown1.Text = "uiDoubleUpDown1"; this.uiDoubleUpDown1.Text = "uiDoubleUpDown1";
this.uiDoubleUpDown1.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
this.uiDoubleUpDown1.Value = 0D; this.uiDoubleUpDown1.Value = 0D;
// //
// uiLine1 // uiLine1
@ -230,6 +235,7 @@
this.uiRichTextBox1.Text = "Blog: https://www.cnblogs.com/yhuse\nGitee: https://gitee.com/yhuse/SunnyUI\nGitHub" + this.uiRichTextBox1.Text = "Blog: https://www.cnblogs.com/yhuse\nGitee: https://gitee.com/yhuse/SunnyUI\nGitHub" +
": https://github.com/yhuse/SunnyUI\nSunnyUI.Net 系列文章目录\n欢迎交流QQ群 56829229 (SunnyU" + ": https://github.com/yhuse/SunnyUI\nSunnyUI.Net 系列文章目录\n欢迎交流QQ群 56829229 (SunnyU" +
"I技术交流群)请给源码项目点个Star吧"; "I技术交流群)请给源码项目点个Star吧";
this.uiRichTextBox1.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
// //
// uiContextMenuStrip1 // uiContextMenuStrip1
// //
@ -285,11 +291,11 @@
this.uiTextBox4.Text = "Blog: https://www.cnblogs.com/yhuse\r\nGitee: https://gitee.com/yhuse/SunnyUI\r\nGitH" + this.uiTextBox4.Text = "Blog: https://www.cnblogs.com/yhuse\r\nGitee: https://gitee.com/yhuse/SunnyUI\r\nGitH" +
"ub: https://github.com/yhuse/SunnyUI\r\nSunnyUI.Net 系列文章目录\r\n欢迎交流QQ群 56829229 (Su" + "ub: https://github.com/yhuse/SunnyUI\r\nSunnyUI.Net 系列文章目录\r\n欢迎交流QQ群 56829229 (Su" +
"nnyUI技术交流群)请给源码项目点个Star吧"; "nnyUI技术交流群)请给源码项目点个Star吧";
this.uiTextBox4.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
this.uiTextBox4.Watermark = "水印文字"; this.uiTextBox4.Watermark = "水印文字";
// //
// FTextBox // FTextBox
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 21F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.ClientSize = new System.Drawing.Size(800, 565); this.ClientSize = new System.Drawing.Size(800, 565);
this.Name = "FTextBox"; this.Name = "FTextBox";

View File

@ -602,18 +602,14 @@ namespace Sunny.UI
/// 文字对齐方向 /// 文字对齐方向
/// </summary> /// </summary>
[Description("文字对齐方向"), Category("SunnyUI")] [Description("文字对齐方向"), Category("SunnyUI")]
[DefaultValue(ContentAlignment.MiddleCenter)]
public ContentAlignment TextAlignment public ContentAlignment TextAlignment
{ {
get => _textAlignment; get => _textAlignment;
set set
{ {
if (_textAlignment != value) _textAlignment = value;
{ TextAlignmentChange?.Invoke(this, value);
_textAlignment = value; Invalidate();
TextAlignmentChange?.Invoke(this, value);
Invalidate();
}
} }
} }

View File

@ -72,6 +72,7 @@ namespace Sunny.UI
bar.ValueChanged += Bar_ValueChanged; bar.ValueChanged += Bar_ValueChanged;
edit.MouseWheel += OnMouseWheel; edit.MouseWheel += OnMouseWheel;
bar.MouseEnter += Bar_MouseEnter; bar.MouseEnter += Bar_MouseEnter;
base.TextAlignment = ContentAlignment.MiddleLeft;
SizeChange(); SizeChange();