惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 叶小钗
D
Docker
GbyAI
GbyAI
Y
Y Combinator Blog
Google DeepMind News
Google DeepMind News
G
Google Developers Blog
P
Proofpoint News Feed
云风的 BLOG
云风的 BLOG
雷峰网
雷峰网
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Stack Overflow Blog
Stack Overflow Blog
WordPress大学
WordPress大学
小众软件
小众软件
Engineering at Meta
Engineering at Meta
酷 壳 – CoolShell
酷 壳 – CoolShell
I
InfoQ
B
Blog
H
Help Net Security
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 聂微东
The GitHub Blog
The GitHub Blog
A
About on SuperTechFans
B
Blog RSS Feed
Microsoft Security Blog
Microsoft Security Blog

博客园 - 糊涂小猪

ASP.NET页面请求流程 工作气氛 程序员的人生 利用reflector工具导出工程文件 按评论数排序会出现两个一模一样的文章,是BUG么? ORACLE中按长度分割字符串(保持单词完整性和数值完整性) CLS理解 starteam 中文手册 不会技术的比会技术的好混,啥世道现在!! ORACLE中批处理的执行 日志文件的生成 C#取得当前窗体图片 MENUITEMS中一个被忽略的属性 继承CollectionBase来扩展自定义的集合类型 C#继承机制 Start without Debugging VS start C#中对ini文件的操作。 C#中提取字符串的解决方法 C#中的[DllImport("kernel32.dll")]的意思是啥?困惑ing。
自定义COMBOBOX控件
糊涂小猪 · 2007-04-18 · via 博客园 - 糊涂小猪

  Windows 窗体 ComboBox 控件用于在下拉组合框中显示数据。默认情况下,ComboBox 控件分两个部分显示:顶部是一个允许用户键入列表项的文本框。第二个部分是列表框.
 我们就是根据它有两部分组成,来实现对现有的COMBOBOX的扩展..CODING  AS FOLLOWWING:

 public class ComboBase : System.Windows.Forms.ComboBox
 {
  System.Data.DataTable oTable = null;
  System.Data.DataView oDv     = null;
  public ComboBase()
  {
   SetIniDrop("disPlay","valPlay");
  }
  private void SetIniDrop(string DisPlay,string ValPlay)
  {
   oTable = new System.Data.DataTable("combo");
   
   oTable.Columns.Add(DisPlay,typeof(string));
   oTable.Columns.Add(ValPlay,typeof(string));  
   oTable.Rows.Add(new object[]{"",""});
   oDv = new System.Data.DataView(oTable,"","",System.Data.DataViewRowState.CurrentRows); 
   
   
   this.DataSource = oDv;
   this.DisplayMember = DisPlay;
   this.ValueMember   = ValPlay;

  }
  public void Add(string[] sender)
  {
   oTable.Rows.Add(sender); 
  }
  
  protected override void OnCreateControl()
  {
   base.OnCreateControl ();
  }

 }
}

让后我们可以通过继承该COMBOBOX来实现COMBOBOX下拉内容的自定义..
 public class MyComBase : ClassLibrary2.ComboBase
 {
  /// <summary>
  public MyComBase()
  {
   
  }
  protected override void OnCreateControl()
  {
   base.Add(new string[]{"1","ENGLISH"});
   base.Add(new string[]{"2","CHINA"});
   base.OnCreateControl ();
  }