ToolStripComboBoxItem箭头绘制中的问题(VS.Net 2010,WinForms). [英] Problem in ToolStripComboBoxItem arrow paint (VS.Net 2010, WinForms).

查看:51
本文介绍了ToolStripComboBoxItem箭头绘制中的问题(VS.Net 2010,WinForms).的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用从ToolStripProfessionalRenderer继承的CustomRenderer渲染工具条.这个概念是我希望工具条项的箭头颜色在所有情况下(选择除外)都为白色.选中后,颜色应为黑色.在我的代码下面,所有的箭头都相应地绘制,除了ToolStripComboBox,其中箭头的颜色始终保持不变;默认的.如何解决呢?

希望我不需要编写整个类,而只需编写相关的片段.所以我只上传了OnRenderArrow方法.

I am rendering a toolstrip with a CustomRenderer that inherits from ToolStripProfessionalRenderer. The concept is that I want the color of the arrow of the toolstrip items to be white in all cases except selection. When it is selected the color should be black. In my code below all arrows are painted accordingly except the ToolStripComboBox where the color of the arrow always remains the same; the default one. How to sort it out?

Hope I don''t need to write the whole class but only the relevant fragment. So I uploaded the OnRenderArrow method only.

Friend Class CustomRenderer
    Inherits ToolStripProfessionalRenderer

    Sub New()
        
    End Sub

    Protected Overrides Sub OnRenderArrow(ByVal e As System.Windows.Forms.ToolStripArrowRenderEventArgs)
        If e.Item.Pressed Then
            e.ArrowColor = Color.White
        ElseIf e.Item.Selected Then
            e.ArrowColor = SystemColors.ControlText
        Else
            e.ArrowColor = Color.White
        End If

        MyBase.OnRenderArrow(e)
    End Sub
End Class



使用相关类渲染工具条:



To render the toolstrip with the pertinent class:

MyToolStrip.Renderer = New CustomRenderer

推荐答案

已你看到这个了吗?

Toolstrip自定义程序

这个小应用程序使使用CustomRenderer自定义UI变得非常容易.
Have you seen this?

Toolstrip Customizer

This little app makes customizing your UI using a CustomRenderer really easy.


ToolStripComboBox实际上是一个常规的ComboBox控件,该控件托管在ToolStripControlHost中.如前所述,ToolStripItem箭头与菜单子项指示符无关,与之无关.我们需要自定义常规ComboBox的绘制.

检查以下内容:
http://social.msdn.microsoft.com /forums/zh-CN/winforms/thread/d846c71b-d405-495f-9b6d-8d0b361a0aac/ [
ToolStripComboBox is actually a regular ComboBox control that is hosted in a ToolStripControlHost. ToolStripItem arrows is as mentioned the menu children indicators and is not related to that. We need to custom paint the regular ComboBox.

Check this:
http://social.msdn.microsoft.com/forums/en-US/winforms/thread/d846c71b-d405-495f-9b6d-8d0b361a0aac/[^]


这篇关于ToolStripComboBoxItem箭头绘制中的问题(VS.Net 2010,WinForms).的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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