本帖最后由 zdl110110 于 2009-12-07 15:51:02 编辑

解决方案 »

  1.   

    在combobox1里的selectIndexChanged事件里给combobox2绑定数据源
      

  2.   

    给你参考下:
        /// <summary>
            /// 初始化
            /// </summary>
            private void Form2_Load(object sender, EventArgs e)
            {
              this.comboDiffLevel.SelectedIndex = 0;      //设置题目难度
                this.comboItemType.SelectedIndex = 0;     //设置试题类型
                this.comshowtype.SelectedIndex = 0;       //设置显示类型
                bindSelectPoolColl();
            }
            /// <summary>
            /// 绑定所有题库集
            /// </summary>
            void bindSelectPoolColl()
            {
                this.comboItemPoolCollection.DataSource = ipcbll.SelectItemPoolcollection();
                this.comboItemPoolCollection.DisplayMember = "Name";
                this.comboItemPoolCollection.ValueMember = "Code";
            }
            /// <summary>
            /// 根据选中题库集绑定题库
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void comboItemPoolCollection_SelectedValueChanged(object sender, EventArgs e)
            {
                this.comboItemPool.Text = "";
                string strParentcode = comboItemPoolCollection.SelectedValue.ToString();
                this.comboItemPool.DataSource = ipcbll.SelectItemPooltk(strParentcode);
                this.comboItemPool.DisplayMember = "Name";
                this.comboItemPool.ValueMember = "Code";
            }
            /// <summary>
            /// 根据选中的题库绑定对应的知识点
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void comboItemPool_SelectedValueChanged(object sender, EventArgs e)
            {
                this.comKnowledge.Text = "";
                if (this.comboItemPool.Text == "")
                {
                    //说明题库为空,对应的知识点也为空
                    this.comKnowledge.Text = "";
                }
                else
                {
                    string strIPCode = comboItemPool.SelectedValue.ToString();
                    this.comKnowledge.DataSource = kdbll.SelectKnowlegecode(strIPCode);
                    this.comKnowledge.DisplayMember = "Name";
                    this.comKnowledge.ValueMember = "IPCode";
                }
            }