public void SetDataSource(BindingSource source, string displayMember = "", string valueMember = "", bool dropdown = false) { if (this.InvokeRequired) { SetComboDataSource dlgt = new SetComboDataSource(SetDataSource); Invoke(dlgt, new object[] { source,displayMember,ValueMember, dropdown }); } else { try { var text = this.Text; if (source == null) this.DataSource = null; else this.DataSource = source.DataSource; if( !String.IsNullOrEmpty( displayMember )) this.DisplayMember = displayMember; if( !String.IsNullOrEmpty( valueMember)) this.ValueMember = ValueMember; //this.SelectedItem = null; //if (this.Text != text) // this.Text = text; //this.SelectionStart = this.Text.Length; //this.DroppedDown = dropdown; } catch { } } }
public void SetDataSource(BindingSource source, string displayMember = "", string valueMember = "") { if (this.InvokeRequired) { SetComboDataSource dlgt = new SetComboDataSource(SetDataSource); Invoke(dlgt, new object[] { source,displayMember,ValueMember }); } else { if (source == null) this.DataSource = null; else this.DataSource = source.DataSource; this.DisplayMember = displayMember; this.ValueMember = ValueMember; } }
public void SetDataSource(BindingSource source, string displayMember = "", string valueMember = "", bool dropdown = false) { if (this.InvokeRequired) { SetComboDataSource dlgt = new SetComboDataSource(SetDataSource); Invoke(dlgt, new object[] { source, displayMember, ValueMember, dropdown }); } else { try { var text = this.Text; if (source == null) { this.DataSource = null; } else { this.DataSource = source.DataSource; } if (!String.IsNullOrEmpty(displayMember)) { this.DisplayMember = displayMember; } if (!String.IsNullOrEmpty(valueMember)) { this.ValueMember = ValueMember; } //this.SelectedItem = null; //if (this.Text != text) // this.Text = text; //this.SelectionStart = this.Text.Length; //this.DroppedDown = dropdown; } catch { } } }