简体   繁体   English

C#Windows窗体,绘制组合框边框

[英]C# Windows Forms, painting combobox borders

We need to show our disabled comboboxes as an image. 我们需要将禁用的组合框显示为图像。 The image has the same height as the standard combobox, but for some reason it cannot override the borders of the combobox. 图像具有与标准组合框相同的高度,但是由于某些原因,它无法覆盖组合框的边界。

Instead, it end up looking like this: 相反,它最终看起来像这样:

1个

We would like them look like this image, ie that the image is shown on top of everything - including the combobox borders: 我们希望它们看起来像此图像,即该图像显示在所有内容的顶部,包括组合框边框:

2

Any ideas? 有任何想法吗?

Thanks. 谢谢。

First of all, what you are trying sounds really dirty - the best way would be, if your ComboBox would just look like your image as soon as you disable it! 首先,您尝试的操作听起来确实很脏-最好的方法是,一旦禁用ComboBox就会看起来像您的图像!

If there is really no other way: 如果真的没有其他方法:

Create a PictureBox in front of your ComboBox . ComboBox前面创建一个PictureBox Set the image as the PictureBox 's image, make it Visible whenever you want to "disable" your ComboBox . 将图像设置为PictureBox的图像,每当您要“禁用” ComboBox时,使其Visible

But again, using controls to simulate behaviour you would expect to be part of another control is dirty . 但是,再次使用控件来模拟行为,您可能希望成为另一个控件的一部分是肮脏的

获取文本框的位置,将其设置为不可见,然后在相同的位置放置一个图像框

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM