• 如何设置 ComboBox 下拉列表的高度或间距


    ComboBox 的下拉列表部分总是很挤,看起不舒服,但是设置了 ItemHeight 没用,怎么办呢?

    首先设置一个较大的 ItemHeight 值,比如 20;

    然后设置 ComboBox 的 DrawMode 为 OwnerDrawVariable;

    然后在 DrawItem 事件中实现如何代码:

    [csharp] view plain copy
     
    1. private void ComboBox1_DrawItem(object sender, DrawItemEventArgs e)  
    2. {  
    3.     if (e.Index < 0)  
    4.     {  
    5.         return;  
    6.     }  
    7.     e.DrawBackground();  
    8.     e.DrawFocusRectangle();  
    9.     e.Graphics.DrawString(ComboBox1.Items[e.Index].ToString(), e.Font, new SolidBrush(e.ForeColor), e.Bounds.X, e.Bounds.Y + 3);  
    10. }  

    ItemHeight 是设置项的高度,但只设置它没用,为什么呢?因为默认的 DrawMode 决定了它不会有用,所以我们将 DrawMode 设置为 OwnerDrawVariable;然后再自己写 DrawItem 事件处理程序,最后一个参数决定了文字顶端要下移,让文字在选项的中间,看起来舒服些。
     
     http://blog.csdn.net/smeller/article/details/7446582
  • 相关阅读:
    关于android4.3 Intel X86 Atom System Image的下载
    dp和px以及sp
    Android项目结构分析
    Performance Testing
    Modifying a Request or Response
    Log Sessions to Local Database
    The Web Sessions List
    Using QuickExec
    AutoResponder Reference
    Fiddler Session标志
  • 原文地址:https://www.cnblogs.com/Echo529/p/6382254.html
Copyright © 2020-2023  润新知