我有三个组合框,使用我在项目中创建的相同数据库。
当我在一个组合框中选择一个选项时,它会用相同的东西填充其他三个。我可以得到它,这样我就可以为每个组合框选择不同的选择。
// fieldBox1
//
this.fieldBox1.DataBindings.Add(new System.Windows.Forms.Binding("SelectedValue", this.fieldsTableBindingSource1, "FieldName", true));
this.fieldBox1.DataSource = this.fieldsTableBindingSource1;
this.fieldBox1.DisplayMember = "FieldName";
this.fieldBox1.FormattingEnabled = true;
this.fieldBox1.Location = new System.Drawing.Point(498, 89);
this.fieldBox1.Name = "fieldBox1";
this.fieldBox1.Size = new System.Drawing.Size(121, 21);
this.fieldBox1.TabIndex = 5;
this.fieldBox1.ValueMember = "FieldName";
this.fieldBox1.SelectedIndexChanged += new System.EventHandler(this.fieldBox1_SelectedIndexChanged);
//
// fieldsDBDataSet1
//
this.fieldsDBDataSet1.DataSetName = "FieldsDBDataSet1";
this.fieldsDBDataSet1.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema;
//
// fieldsTableBindingSource1
//
this.fieldsTableBindingSource1.DataMember = "FieldsTable";
this.fieldsTableBindingSource1.DataSource = this.fieldsDBDataSet1;
//
// fieldsTableBindingSource
//
this.fieldsTableBindingSource.AllowNew = false;
this.fieldsTableBindingSource.DataMember = "FieldsTable";
this.fieldsTableBindingSource.DataSource = this.fieldsDBDataSet1;
//
// fieldBox2
//
this.fieldBox2.DataBindings.Add(new System.Windows.Forms.Binding("SelectedValue", this.fieldsTableBindingSource, "FieldName", true));
this.fieldBox2.DataSource = this.fieldsTableBindingSource;
this.fieldBox2.DisplayMember = "FieldName";
this.fieldBox2.FormattingEnabled = true;
this.fieldBox2.Location = new System.Drawing.Point(498, 116);
this.fieldBox2.Name = "fieldBox2";
this.fieldBox2.Size = new System.Drawing.Size(121, 21);
this.fieldBox2.TabIndex = 6;
this.fieldBox2.ValueMember = "FieldName";
//
// fieldsTableBindingSource2
//
this.fieldsTableBindingSource2.DataMember = "FieldsTable";
this.fieldsTableBindingSource2.DataSource = this.fieldsDBDataSet1;
//
// fieldBox3
//
this.fieldBox3.DataBindings.Add(new System.Windows.Forms.Binding("SelectedValue", this.fieldsDBDataSet1, "FieldsTable.FieldName", true));
this.fieldBox3.DataSource = this.fieldsTableBindingSource3;
this.fieldBox3.DisplayMember = "FieldName";
this.fieldBox3.FormattingEnabled = true;
this.fieldBox3.Location = new System.Drawing.Point(498, 140);
this.fieldBox3.Name = "fieldBox3";
this.fieldBox3.Size = new System.Drawing.Size(121, 21);
this.fieldBox3.TabIndex = 7;
this.fieldBox3.ValueMember = "FieldName";
//
// fieldsTableBindingSource3
//
this.fieldsTableBindingSource3.DataMember = "FieldsTable";
this.fieldsTableBindingSource3.DataSource = this.fieldsDBDataSet1;
任何帮助都将是重大帮助。