gpt4 book ai didi

c# - 去除左右边框

转载 作者:太空宇宙 更新时间:2023-11-03 13:45:23 29 4
gpt4 key购买 nike

我希望我的 TextBox 看起来像这样
enter image description here

如何删除 TextBox 控件的左侧和右侧?

最佳答案

通常,您必须覆盖 OnPaint 事件才能执行此操作,但是对于文本框,这将不起作用,因为不会调用 OnPaint。

一种方法是将 TextBox 子类化,如 here 所述

但是我根本不建议你这样做,这对我来说听起来像是一项艰巨的任务(我自己从来没有这样做过),尤其是当你刚接触编程时。

也许只在 TextBox 上方或下方画一条线就足够了?

-编辑-

也许这会更好地解释它:

The TextBox is special in that you can't custom paint it. If you just want a custom border, you can create a new UserControl and add a TextBox with border style set to None. Make sure you leave enough room around the outside of the TextBox for a border. Then paint the border on the UserControl surface. An alternative method would be to handle the WM_NCPAINT message of the TextBox and paint the border then, but that is significantly more complicated.

来源:msdn 论坛中的 shawn.ohern:here(对不起,我不知道如何直接链接到他的帖子)

-edit2-link展示了一种创建您自己的 TextBox 的方法,同样,我不会向刚接触 c# 和编程的人推荐这种方法 ;)

关于c# - 去除左右边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15543522/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com