在WinForm程序中,实现TextBox文本输入框占位符的方式也很多,最常用的是方式基于Windows Api SendMessage函数发送EM_SETCUEBANNER消息,或者通过TextBox自带的焦点事件处理。 SendMessage函数实现 创建一个继承TextBox的ZhmTextBox输入框控件,新增Placeholder属性,在Placeholder的set方法中发送EM_SETCUEBANNER消息 public class Zh...
private void Form1_Load(object sender, EventArgs e) { textBox1.Text = "此处是一些提示内容..."; textBox1.LostFocus += TextBox1_LostFocus; textBox1.GotFocus += TextBox1_GotFocus; } private void TextBox1_GotFocus(object sender, EventArgs e) { textBox1.Text = ""; } private void Te...
程序集: System.Windows.Forms.dll 获取或设置当控件没有文本且不具有焦点时要显示的文本。 C# 复制 public virtual string PlaceholderText { get; set; } 属性值 String 控件没有文本且没有焦点时显示的文本。 适用于 产品版本 Windows Desktop 3.0, 3.1, 5, 6, 7 本文内容 定义 适用于 中文...
public string PlaceholderText { get; set; } XAML 复制 <TextBox PlaceholderText="placeholderString"/> 属性值 String 未输入任何值时控件中显示的文本。 默认值为空字符串("")。 适用于 产品版本 WinRT Build 10240, Build 10586, Build 14383, Build 15063, Build 16299, Build 17134, Build 17763...
TextBox.PlaceholderForegroundProperty PropertyReference Feedback DefinitionNamespace: Windows.UI.Xaml.Controls Edit Identifies the PlaceholderForeground dependency property. C# Αντιγραφή public static DependencyProperty PlaceholderForegroundProperty { get; } Property Value DependencyProperty The ...
Gets or sets the text that is displayed in the control until the value is changed by a user action or some other operation. C# Copy public string PlaceholderText { get; set; } XAML Copy <TextBox PlaceholderText="placeholderString"/> Property Value String The text that is displayed ...
System.Drawing.Size(284, 264); this.Controls.Add(this.textBox1); this.Text = "TextBox Example"; this.ResumeLayout(false); this.PerformLayout(); } [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()...
System.Drawing.Size(284, 264); this.Controls.Add(this.textBox1); this.Text = "TextBox Example"; this.ResumeLayout(false); this.PerformLayout(); } [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()...
System.Drawing.Size(284, 264); this.Controls.Add(this.textBox1); this.Text = "TextBox Example"; this.ResumeLayout(false); this.PerformLayout(); } [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()...
System.Drawing.Size(284, 264); this.Controls.Add(this.textBox1); this.Text = "TextBox Example"; this.ResumeLayout(false); this.PerformLayout(); } [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()...