C#笔记(5)textbox的hint属性
来源:互联网 发布:mac 彻底删除office 编辑:程序博客网 时间:2024/05/21 18:03
新建类
public static class Win32Utility { [DllImport("user32.dll", CharSet = CharSet.Auto)] private static extern Int32 SendMessage(IntPtr hWnd, int msg, int wParam, [MarshalAs(UnmanagedType.LPWStr)] string lParam); [DllImport("user32.dll")] private static extern bool SendMessage(IntPtr hwnd, int msg, int wParam, StringBuilder lParam); [DllImport("user32.dll")] private static extern bool GetComboBoxInfo(IntPtr hwnd, ref COMBOBOXINFO pcbi); [StructLayout(LayoutKind.Sequential)] private struct COMBOBOXINFO { public int cbSize; public RECT rcItem; public RECT rcButton; public IntPtr stateButton; public IntPtr hwndCombo; public IntPtr hwndItem; public IntPtr hwndList; } [StructLayout(LayoutKind.Sequential)] private struct RECT { public int left; public int top; public int right; public int bottom; } private const int EM_SETCUEBANNER = 0x1501; private const int EM_GETCUEBANNER = 0x1502; public static void SetCueText(Control control, string text) { if (control is ComboBox) { COMBOBOXINFO info = GetComboBoxInfo(control); SendMessage(info.hwndItem, EM_SETCUEBANNER, 0, text); } else { SendMessage(control.Handle, EM_SETCUEBANNER, 0, text); } } private static COMBOBOXINFO GetComboBoxInfo(Control control) { COMBOBOXINFO info = new COMBOBOXINFO(); //a combobox is made up of three controls, a button, a list and textbox; //we want the textbox info.cbSize = Marshal.SizeOf(info); GetComboBoxInfo(control.Handle, ref info); return info; } public static string GetCueText(Control control) { StringBuilder builder = new StringBuilder(); if (control is ComboBox) { COMBOBOXINFO info = new COMBOBOXINFO(); //a combobox is made up of two controls, a list and textbox; //we want the textbox info.cbSize = Marshal.SizeOf(info); GetComboBoxInfo(control.Handle, ref info); SendMessage(info.hwndItem, EM_GETCUEBANNER, 0, builder); } else { SendMessage(control.Handle, EM_GETCUEBANNER, 0, builder); } return builder.ToString(); } }
2.使用
Win32Utility.SetCueText(textBox_username, "用户名");Win32Utility.SetCueText(textBox_password, "密码");
阅读全文
0 0
- C#笔记(5)textbox的hint属性
- C#关于textbox的text属性
- C#设置textBox字体属性
- C# 改变窗体中所有TextBox控件的属性
- textbox的ontextchange属性。
- TextBox的ReadOnly属性
- TextBox属性的学习
- textbox的属性设置
- asp:textbox 的属性
- Oracle Hint的用法(HINT提示)
- c# 遍历页面TextBox-笔记
- android:hint属性对TextView的影响
- TextBox的EnableViewState属性问题
- C# .NET 遍历一个Web页面中所有的TextBox控件 并设置读写属性
- android:hint属性(没有输入内容之前的提示内容)
- Delphi的Hint(1)
- Oracle Hint(/* ..... */)的用法
- C#学习笔记:控件的字体(Font)属性设置
- poj 1422 Air Raid(最小不相交路径覆盖)
- Java笔记--04
- matlab将矩阵化成行最简形
- Sqoop 简介及安装部署
- 中国大学MOOC·Python网络爬虫与信息提取(一)
- C#笔记(5)textbox的hint属性
- 爬虫实战12—自动摘要及正文抽取
- JavaWeb Session 之表单的重复提交
- Mycat概述
- SVM之对偶问题
- Mathematical Field of Experiments (打表)
- 深度优先搜索—C—python
- exit函数
- SVM之核函数