原文地址:http://bbs.csdn.net/topics/390135022

http://blog.csdn.net/scsdn/article/details/4363299

想使用winform的combox控件,但是觉得控件太小了,想在触摸屏上使用,感觉combox后面的下拉选择的三角形太小了,combox的宽度也太小了,请问下,combox的这些属性,可以更改吗?能够使小三角形大一些嘛?能够使combox的宽度宽些不?请大家给予帮助,谢谢

设置字体可以使得combobox变大。

combobox,listview等一些控件的外观会由于字体大小的改变而改变。

这个没办法。
除非重绘
http://blog.csdn.net/scsdn/article/details/4363299

关于如何重载ComboBox 使其下拉按钮(带下箭头的)和下拉列表的垂直滚动条的宽度改变的问题,通过自绘自定义控件得以解决。

ComboBoxDIY.cs文件

  1. //ComboBoxDIY.cs
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Drawing;
  6. using System.Data;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. namespace WindowsApplication7
  10. {
  11. public partial class ComboBoxDIY : UserControl
  12. {
  13. public bool buttondown = false;
  14. public ComboBoxDIY()
  15. {
  16. InitializeComponent();
  17. this.listBox1.Visible = false;
  18. this.vScrollBar1.Visible = false;
  19. }
  20. private void button1_Click(object sender, EventArgs e)
  21. {
  22. //下拉按钮未曾按下
  23. if (this.buttondown==false)
  24. {
  25. //listbox所有数据的项数
  26. int count = this.listBox1.Items.Count;
  27. //获取listbox所能显示的项数
  28. int displaycount = this.listBox1.Height / this.listBox1.ItemHeight;
  29. //滚动条显示的最大值
  30. int scrollmax = 0;
  31. //垂直方向上显示内容数目大于所能显示的数目时
  32. //垂直滚动条直接可见
  33. if (count > displaycount)
  34. {
  35. scrollmax = count - 1;
  36. this.vScrollBar1.Visible = true;
  37. }
  38. this.vScrollBar1.LargeChange = displaycount;
  39. this.vScrollBar1.Maximum = scrollmax;
  40. this.vScrollBar1.Minimum = 0;
  41. this.vScrollBar1.Scroll += new ScrollEventHandler(vscroll);
  42. this.listBox1.Visible = true;
  43. //下拉按钮按下
  44. this.buttondown = true;
  45. }
  46. //下拉按钮已按下
  47. else
  48. {
  49. if(this.vScrollBar1.Visible)this.vScrollBar1.Visible = false;
  50. this.listBox1.Visible = false;
  51. //下拉按钮弹起
  52. this.buttondown = false;
  53. }
  54. }
  55. private void vscroll(object sender, ScrollEventArgs e)
  56. {
  57. //ScrollBar控制listBox滚动
  58. this.listBox1.TopIndex=e.NewValue;
  59. }
  60. private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
  61. {
  62. //文本框显示选择结果
  63. this.textBox1.Text =this.listBox1.Items[this.listBox1.SelectedIndex].ToString();
  64. this.vScrollBar1.Visible = false;
  65. this.listBox1.Visible = false;
  66. //下拉按钮弹起
  67. this.buttondown = false;
  68. }
  69. }
  70. }

//ComboBoxDIY.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication7
{
public partial class ComboBoxDIY : UserControl
{
public bool buttondown = false;
public ComboBoxDIY()
{
InitializeComponent();
this.listBox1.Visible = false;
this.vScrollBar1.Visible = false;
}

private void button1_Click(object sender, EventArgs e)
{
//下拉按钮未曾按下
if (this.buttondown==false)
{
//listbox所有数据的项数
int count = this.listBox1.Items.Count;
//获取listbox所能显示的项数
int displaycount = this.listBox1.Height / this.listBox1.ItemHeight;
//滚动条显示的最大值
int scrollmax = 0;
//垂直方向上显示内容数目大于所能显示的数目时
//垂直滚动条直接可见
if (count > displaycount)
{
scrollmax = count - 1;
this.vScrollBar1.Visible = true;
}
this.vScrollBar1.LargeChange = displaycount;
this.vScrollBar1.Maximum = scrollmax;
this.vScrollBar1.Minimum = 0;
this.vScrollBar1.Scroll += new ScrollEventHandler(vscroll);

this.listBox1.Visible = true;
//下拉按钮按下
this.buttondown = true;
}
//下拉按钮已按下
else
{
if(this.vScrollBar1.Visible)this.vScrollBar1.Visible = false;
this.listBox1.Visible = false;
//下拉按钮弹起
this.buttondown = false;
}
}

private void vscroll(object sender, ScrollEventArgs e)
{
//ScrollBar控制listBox滚动
this.listBox1.TopIndex=e.NewValue;
}

private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
//文本框显示选择结果
this.textBox1.Text =this.listBox1.Items[this.listBox1.SelectedIndex].ToString();
this.vScrollBar1.Visible = false;
this.listBox1.Visible = false;
//下拉按钮弹起
this.buttondown = false;
}
}
}

ComboBoxDIY.Designer.cs文件

  1. //ComboBoxDIY.Designer.cs
  2. namespace WindowsApplication7
  3. {
  4. partial class ComboBoxDIY
  5. {
  6. /// <summary>
  7. /// 必需的设计器变量。
  8. /// </summary>
  9. private System.ComponentModel.IContainer components = null;
  10. /// <summary>
  11. /// 清理所有正在使用的资源。
  12. /// </summary>
  13. /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
  14. protected override void Dispose(bool disposing)
  15. {
  16. if (disposing && (components != null))
  17. {
  18. components.Dispose();
  19. }
  20. base.Dispose(disposing);
  21. }
  22. #region 组件设计器生成的代码
  23. /// <summary>
  24. /// 设计器支持所需的方法 - 不要
  25. /// 使用代码编辑器修改此方法的内容。
  26. /// </summary>
  27. private void InitializeComponent()
  28. {
  29. this.button1 = new System.Windows.Forms.Button();
  30. this.textBox1 = new System.Windows.Forms.TextBox();
  31. this.listBox1 = new System.Windows.Forms.ListBox();
  32. this.vScrollBar1 = new System.Windows.Forms.VScrollBar();
  33. this.SuspendLayout();
  34. //
  35. // button1
  36. //
  37. this.button1.Location = new System.Drawing.Point(85, 0);
  38. this.button1.Name = "button1";
  39. this.button1.Size = new System.Drawing.Size(65, 44);
  40. this.button1.TabIndex = 0;
  41. this.button1.Text = "▼";
  42. this.button1.UseVisualStyleBackColor = true;
  43. this.button1.Click += new System.EventHandler(this.button1_Click);
  44. //
  45. // textBox1
  46. //
  47. this.textBox1.Font = new System.Drawing.Font("宋体", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
  48. this.textBox1.Location = new System.Drawing.Point(0, 0);
  49. this.textBox1.Name = "textBox1";
  50. this.textBox1.Size = new System.Drawing.Size(88, 44);
  51. this.textBox1.TabIndex = 1;
  52. //
  53. // listBox1
  54. //
  55. this.listBox1.Font = new System.Drawing.Font("宋体", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
  56. this.listBox1.FormattingEnabled = true;
  57. this.listBox1.ItemHeight = 33;
  58. this.listBox1.Items.AddRange(new object[] {
  59. "0",
  60. "1",
  61. "2",
  62. "3",
  63. "4",
  64. "5",
  65. "6",
  66. "7",
  67. "8",
  68. "9"});
  69. this.listBox1.Location = new System.Drawing.Point(0, 44);
  70. this.listBox1.Name = "listBox1";
  71. this.listBox1.Size = new System.Drawing.Size(148, 103);
  72. this.listBox1.TabIndex = 2;
  73. this.listBox1.SelectedIndexChanged += new System.EventHandler(this.listBox1_SelectedIndexChanged);
  74. //
  75. // vScrollBar1
  76. //
  77. this.vScrollBar1.Location = new System.Drawing.Point(85, 44);
  78. this.vScrollBar1.Name = "vScrollBar1";
  79. this.vScrollBar1.Size = new System.Drawing.Size(63, 103);
  80. this.vScrollBar1.TabIndex = 3;
  81. //
  82. // UserControl1
  83. //
  84. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
  85. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  86. this.Controls.Add(this.vScrollBar1);
  87. this.Controls.Add(this.listBox1);
  88. this.Controls.Add(this.textBox1);
  89. this.Controls.Add(this.button1);
  90. this.Name = "UserControl1";
  91. this.Size = new System.Drawing.Size(149, 148);
  92. this.ResumeLayout(false);
  93. this.PerformLayout();
  94. }
  95. #endregion
  96. private System.Windows.Forms.Button button1;
  97. private System.Windows.Forms.TextBox textBox1;
  98. private System.Windows.Forms.ListBox listBox1;
  99. private System.Windows.Forms.VScrollBar vScrollBar1;
  100. }
  101. }

如何重载ComboBox 使其下拉按钮(带下箭头的)和下拉列表的垂直滚动条的宽度改变?(自绘ComboBox) [转]的更多相关文章

  1. Qt中QComboBox中自定义界面使用stylesheet实现下拉按钮独立效果

    使用QSS自定义控件界面时,QT中控件QCombobox含有两个子控件drop-down和down-arrow.一般而言,当改变QCombox时,很多效果都会出来,但是,针对下拉按钮和下拉图标的自定义 ...

  2. 重绘ComboBox —— 让ComboBox多列显示

    最近在维护一个winform项目,公司购买的是DevExpress控件 (请问怎么联系DevExpress工作人员? 我想询问下,广告费是怎么给的.:p),经过公司大牛们对DevExpress控件疯狂 ...

  3. Bootstrap页面布局15 - BS带下拉菜单的按钮

    带下拉菜单的按钮 <div class='btn-toolbar'> <div class='btn-group'> <a href='javascript:;' cla ...

  4. EazyUI_Datagrid_行内编辑(editor)的combobox下拉框带图片

    1.业务需求: 商品的明细列表里面下拉框需要 [图片+文字 ] 显示 2.我们使用的是EazyUI,而我比较懒,不习惯用拼接html来显示列表页面,使用的是eazyui的数据网格(datagrid) ...

  5. 转:控制ComboBox下拉框的下拉部分宽度,使内容能够显示完全

    一般的情况下,如果下拉框的选项的文字太长,下拉框ComboBox的Width宽度属性我们又不想要改变(默认不变),下拉选项的文字内容就会被截剪,如下图所示: 解决办法: 1.自动判断下拉选项的文字长度 ...

  6. easyui combobox点击输入框弹出下拉框

    由于easyui combobox需要点击下拉箭头才能下拉,不能像select标签那样点击输入框就下拉,所以觉得不太方便,查看了一下,combobox弹出框是一个div,原本想在他的输入框的点击事件中 ...

  7. 修改select下拉框的下拉按钮

    ie上的下拉框下拉按钮真是太丑了,如何把他自定义一下呢? 首先,把浏览器自带的下拉框去掉:  select::-ms-expand { display: none; } 接下来,用自己喜欢的下拉图片去 ...

  8. jquery带下拉菜单和焦点图

    jQuery,下拉菜单,二级菜单,索引按钮,焦点图代码,jquery带下拉菜单和焦点图是一款顶部通栏带二级下拉菜单和banner导航菜单代码. JQuery特效代码来源:http://www.huiy ...

  9. Bootstrap单按钮的下拉菜单

    简介 把任意一个按钮放入 .btn-group 中,然后加入适当的菜单标签,就可以让按钮作为菜单的触发器了. 插件依赖 按钮式下拉菜单依赖下拉菜单插件 ,因此需要将此插件包含在你所使用的 Bootst ...

随机推荐

  1. PullToRefreshListView调用onRefreshComplete方法 无法取消刷新的bug

    我们在使用框架:   PullToRefreshListView 实现下拉或者上拉加载时候,可能在上拉 完成时候,调用onRefreshComplete方法去 停止 刷新操作,但是,可能无效,测试产生 ...

  2. lua字符匹配

    匹配下列格式的数据中的 source和MAC地址: Chain WiFiDog_br-lan_Outgoing (1 references) pkts bytes target prot opt in ...

  3. innodb结构解析工具---innodb_ruby

    1.下载ruby并安装ruby: ftp://ftp.ruby-lang.org/pub/ruby/ ftp://ftp.ruby-lang.org/pub/ruby/ruby-2.3-stable. ...

  4. Linux进程学习(孤儿进程和守护进程)

    孤儿进程和守护进程 通过前面的学习我们了解了如何通过fork()函数和vfork()函数来创建一个进程.现在 我们继续深入来学习两个特殊的进程:孤儿进程和守护进程 一.孤儿进程 1.什么是 孤儿进程如 ...

  5. WCF - 契约

    契约就是双方或多方就某个问题达成的一种的共识  服务提供者通过契约的形式将服务公布出来 服务消费者根据契约来消费 这样通过契约这个中间者就可以规范服务提供的内容 而服务消费者也可以根据契约来使用服务端 ...

  6. 后端接收不到AngularJs中$http.post发送的数据的问题

    1.问题: 后端接收不到AngularJs中$http.post发送的数据,总是显示为null 示例代码: $http.post(/admin/KeyValue/GetListByPage, { pa ...

  7. WPF converter

    单值转换器 将单一值转换为特定类型的值,以日期转换为例如下: 1.定制DateConverter类,其中当值从绑定源传播给绑定目标时,调用方法Convert. 1 public class DateC ...

  8. WPF DataGrid某列使用多绑定后该列排序失效,列上加入 SortMemberPath 设置即可.

    WPF DataGrid某列使用多绑定后该列排序失效 2011-07-14 10:59hdongq | 浏览 1031 次  悬赏:20 在wpf的datagrid中某一列使用了多绑定,但是该列排序失 ...

  9. codevs1380 没有丧尸的舞会

    /* 树形DP 而然我并不知道树在哪(....) f[x][0]表示x节点不参加舞会 以x为根的子树的最优解 f[x][1]表示x节点参加舞会 以x为根的子树的最优解 方程为:(so为x的儿子 so要 ...

  10. js substr和substring字符串截取

    substr(start,length)第一个参数是开始位置(注:start的开始是从0开始,看到好多博客上面是从1开始,在火狐和谷歌执行了一下是从0开始),第二个参数是截取字符串的长度(可以省略,表 ...