当前位置: 代码网 > it编程>编程语言>Asp.net > C#TextBox设置提示文本方式(SetHintText)

C#TextBox设置提示文本方式(SetHintText)

2025年04月15日 Asp.net 我要评论
c#textbox设置提示文本效果展示核心代码[dllimport("user32.dll", charset = charset.auto)]private static extern int32

c#textbox设置提示文本

效果展示

核心代码

[dllimport("user32.dll", charset = charset.auto)]
private static extern int32 sendmessage(intptr hwnd, int msg, int wparam, [marshalas(unmanagedtype.lpwstr)] string lparam);

public static void sethinttext(control control, string text)
{
    sendmessage(control.handle, 0x1501, 0, text);
}
public frmupdatapassword()
{
    initializecomponent();
    sethinttext(txt_oldpassword, "初始密码为:123456");
    sethinttext(txt_newpassword, $"6-{txt_newpassword.maxlength}位数字或字母");
    btn_enter.focus();
}

//显示/隐藏密码
private void chb_showpassword_checkedchanged(object sender, eventargs e)
{
    //txt_oldpassword.usesystempasswordchar = !chb_showpassword.checked;
    txt_newpassword.usesystempasswordchar = !chb_showpassword.checked;

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com