在Combobox中对齐文本 [英] Align Text in Combobox

查看:308
本文介绍了在Combobox中对齐文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将我的文本在组合框中,以便它将显示在组合框的中心告诉我如何做到这一点,你也可以看到有一个默认边框周围的组合框,当它是焦点如何我可以删除那边框也
请解决我的两个问题
感谢

I want to align my text in combo box so that it will show in the center of combobox tell me how to do this also you can see there is a default border around a combo box when it is in focus how can i remove that border also Kindly solve my two problems Thanks

推荐答案

这不是ComboBox支持的。确切的原因在时间的迷雾中失去了,ComboBox自九十年代初以来一直存在,但是确实与在文本框部分中获取文本以与下拉列表中的文本对齐的尴尬有关。使用DrawItem的自定义绘图也无法解决它,只会影响下拉项的外观。

This isn't supported for ComboBox. The exact reasons are lost in the fog of time, ComboBox has been around since the early nineties, but surely has something to do with the awkwardness of getting the text in the textbox portion to line up with the text in the dropdown. Custom drawing with DrawItem cannot solve it either, that only affects the appearance of the dropdown items.

作为一种可能的解决方法,你可能做一些异常填充项目字符串使用空格,使他们看起来居中。您需要使用TextRenderer.MeasureText()来确定每个项目要添加多少空格。

As a possible workaround, you could perhaps do something outlandish like padding the item strings with spaces so they look centered. You'll need TextRenderer.MeasureText() to figure out how many spaces to add for each item.

您正在说的边框不是边框,是焦点矩形。你也不能摆脱这一点,Windows拒绝让你创建一个UI,不会显示控件与焦点。喜欢键盘而不是鼠标的用户关心。没有解决方法。

The "border" you are talking about is not a border, it is the focus rectangle. You can't get rid of that either, Windows refuses to let you create a UI that won't show the control with the focus. Users that prefer the keyboard over the mouse care about that. No workaround for that one.

这篇关于在Combobox中对齐文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆