爱问知识人 爱问教育 医院库

一个c#简单的问题~~

首页

一个c#简单的问题~~

怎么在c#的comboBox控件里面面添加数据库里面的东西~~它和dropdownlist控件有什么区别~~
怎么让两个comboBox连接起来~~比如
我第一个控件comboBox显示两个数据~~(国产车,和进口车)
第二个控件comboBox分别显示他们里面的东西
~~当点国产车的时候~~第二个comboBox就显示所有的国产车~~
显示进口车的时候就显示所有的进口车~~哪位大哥大姐说明一下~~实例最好啦100分献上~~

提交回答
好评回答
  • 2007-08-21 19:54:21
      DropDownList是web上的控件;ComboBox是winform的控件。
    假设窗体叫Form1;
    显示国产车和进口车的ComboBox叫comboBox1;
    显示具体品牌的ComboBox叫comboBox2。
    完成Form1_Load和comboBox1_SelectedIndexChanged这两个事件的代码。
       private void Form1_Load(object sender, System。EventArgs e) { comboBox1。Items。Add("国产车"); comboBox1。Items。
      Add("进口车"); comboBox1。SelectedIndex = 0; } private void comboBox1_SelectedIndexChanged(object sender, System。EventArgs e) { comboBox2。
      Items。Clear(); if(comboBox1。Text=="国产车") { comboBox2。Items。Add("北京吉普"); comboBox2。Items。Add("上海大众"); comboBox2。
      Items。Add("北京现代"); comboBox2。SelectedIndex = 0; } else if(comboBox1。Text=="进口车") { comboBox2。Items。
      
      Add("保时捷"); comboBox2。Items。Add("奔驰"); comboBox2。Items。Add("法拉利"); comboBox2。SelectedIndex = 0; } }。

    E***

    2007-08-21 19:54:21

其他答案

    2007-08-22 14:36:24
  •   DropDownList是web上的控件;ComboBox是winform的控件。 
    假设窗体叫Form1; 
    显示国产车和进口车的ComboBox叫comboBox1; 
    显示具体品牌的ComboBox叫comboBox2。 
    完成Form1_Load和comboBox1_SelectedIndexChanged这两个事件的代码。
       private void Form1_Load(object sender, System。EventArgs e) { comboBox1。Items。Add("国产车"); comboBox1。Items。Add("进口车"); comboBox1。
      SelectedIndex = 0; } private void comboBox1_SelectedIndexChanged(object sender, System。EventArgs e) { comboBox2。Items。
      Clear(); if(comboBox1。Text=="国产车") { comboBox2。Items。Add("北京吉普"); comboBox2。Items。Add("上海大众"); comboBox2。Items。
      Add("北京现代"); comboBox2。SelectedIndex = 0; } else if(comboBox1。Text=="进口车") { comboBox2。Items。Add("保时捷"); comboBox2。
      Items。Add("奔驰"); comboBox2。Items。Add("法拉利"); comboBox2。SelectedIndex = 0; } } 。

    h***

    2007-08-22 14:36:24

类似问题

换一换
  • C#/.NET 相关知识

  • 电脑网络技术
  • 电脑网络

相关推荐

正在加载...
最新问答 推荐信息 热门专题 热点推荐
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200

热点检索

  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
返回
顶部
帮助 意见
反馈

确定举报此问题

举报原因(必选):