PDA

View Full Version : سوال: مشکل بایندینگ کردن کمبو باکس به دیتابیس



hercool
جمعه 04 مرداد 1392, 20:19 عصر
سلام خدمت دوستان
من از طریق ویزارد خود کمبو باکس و بایند کردن مقادیر کمبو رو از دیتابیس می گیرم اما موقعی که می خوام کمبو دومم رو بر اساس یک شرط مقادیر رو پر کنم دچار مشکل میشم
می خوام کمبو دوم بر اساس مقدار هر عضو در جدولی که بهش متصل هست بگرده و تنها اون رکورد هایی که برابر چنین شماره ای هست رو انتخاب کنه و نشون داده بشه
اما سیستم برام تول استریپ می اره که به کار من نمیاد و می خوام تو خود کمبو باکس دوم به صورت خودکار این کار انجام بشه
public partial class Form1 : Form
{
string valuei;
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'companyDataSet1.company' table. You can move, or remove it, as needed.
this.companyTableAdapter.Fill(this.companyDataSet1 .company);
// TODO: This line of code loads data into the 'bourseDataSet.Industry' table. You can move, or remove it, as needed.
this.industryTableAdapter.Fill(this.bourseDataSet. Industry);

}

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
// textBox1.Text = comboBox1.SelectedValue;
}

private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
{
valuei = comboBox1.SelectedValue.ToString();

}



}
کد بخش دیزاین
namespace combo
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.industryBindingSource = new System.Windows.Forms.BindingSource(this.components );
this.bourseDataSet = new combo.bourseDataSet();
this.industryTableAdapter = new combo.bourseDataSetTableAdapters.IndustryTableAdap ter();
this.comboBox2 = new System.Windows.Forms.ComboBox();
this.companyBindingSource = new System.Windows.Forms.BindingSource(this.components );
this.companyDataSet1 = new combo.companyDataSet1();
this.companyTableAdapter = new combo.companyDataSet1TableAdapters.companyTableAda pter();
this.textBox1 = new System.Windows.Forms.TextBox();
((System.ComponentModel.ISupportInitialize)(this.i ndustryBindingSource)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.b ourseDataSet)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.c ompanyBindingSource)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.c ompanyDataSet1)).BeginInit();
this.SuspendLayout();
//
// comboBox1
//
this.comboBox1.DataBindings.Add(new System.Windows.Forms.Binding("SelectedValue", this.industryBindingSource, "incode", true));
this.comboBox1.DataSource = this.industryBindingSource;
this.comboBox1.DisplayMember = "inname";
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Location = new System.Drawing.Point(98, 65);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(121, 21);
this.comboBox1.TabIndex = 0;
this.comboBox1.ValueMember = "incode";
this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexCh anged);
//
// industryBindingSource
//
this.industryBindingSource.DataMember = "Industry";
this.industryBindingSource.DataSource = this.bourseDataSet;
//
// bourseDataSet
//
this.bourseDataSet.DataSetName = "bourseDataSet";
this.bourseDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema;
//
// industryTableAdapter
//
this.industryTableAdapter.ClearBeforeFill = true;
//
// comboBox2
//
this.comboBox2.DataBindings.Add(new System.Windows.Forms.Binding("SelectedValue", this.companyBindingSource, "codem", true));
this.comboBox2.DataSource = this.companyBindingSource;
this.comboBox2.DisplayMember = "namecompany";
this.comboBox2.FormattingEnabled = true;
this.comboBox2.Location = new System.Drawing.Point(397, 64);
this.comboBox2.Name = "comboBox2";
this.comboBox2.Size = new System.Drawing.Size(121, 21);
this.comboBox2.TabIndex = 1;
this.comboBox2.ValueMember = "codecompany";
this.comboBox2.SelectedIndexChanged += new System.EventHandler(this.comboBox2_SelectedIndexCh anged);
//
// companyBindingSource
//
this.companyBindingSource.DataMember = "company";
this.companyBindingSource.DataSource = this.companyDataSet1;
//
// companyDataSet1
//
this.companyDataSet1.DataSetName = "companyDataSet1";
this.companyDataSet1.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema;
//
// companyTableAdapter
//
this.companyTableAdapter.ClearBeforeFill = true;
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(98, 157);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 20);
this.textBox1.TabIndex = 2;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(646, 436);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.comboBox2);
this.Controls.Add(this.comboBox1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.i ndustryBindingSource)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.b ourseDataSet)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.c ompanyBindingSource)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.c ompanyDataSet1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion

private System.Windows.Forms.ComboBox comboBox1;
private bourseDataSet bourseDataSet;
private System.Windows.Forms.BindingSource industryBindingSource;
private bourseDataSetTableAdapters.IndustryTableAdapter industryTableAdapter;
private System.Windows.Forms.ComboBox comboBox2;
private companyDataSet1 companyDataSet1;
private System.Windows.Forms.BindingSource companyBindingSource;
private companyDataSet1TableAdapters.companyTableAdapter companyTableAdapter;
private System.Windows.Forms.TextBox textBox1;
}
}