ComboBoxEditバインドされたデータソース



Comboboxedit Bound Data Source



キーワードを検索します。

'DataBindings' + 'ComboBoxEdit'



DevExpressの公式オンライン検索であるComboBoxEditバインディング使用状況データソースでは、結果は私に教えてくれませんでしたLookUpEditを使用する必要があります。それで私たちは彼のビットを実現することに決めました、そして今あなたと共有してください!

1、ソースコード:Experiment4Control.cs



システムを使用する

System.Collections.Genericを使用する

System.ComponentModelを使用する



System.Dataを使用する

System.Drawingを使用する

System.Textを使用する

System.Windows.Formsを使用する

DevExpress.XtraEditorsを使用する

名前空間TutorialSLN

{{

パブリック部分クラスExperiment4Control:DevExpress.XtraEditors.XtraForm

{{

プライベートDeptEntityitsDeptEntity

public Experiment4Control()

{{

InitializeComponent()

itsDeptEntity = new DeptEntity()

itsDeptEntity.DeptName = '財務省 '

BindingComboEdit(this.comboBoxEdit1、itsDeptEntity、 'DeptName')

}

void BindingComboEdit(ComboBoxEdit edit、object dataSource、string bindField)

{{

試してみてください

{{

edit.DataBindings.Clear()

バインディングb = new Binding( 'EditValue'、dataSource、bindField)

edit.DataBindings.Add(b)

}

キャッチ(例外例)

{{

//Msg.ShowException(ex)

XtraMessageBox.Show(ex.ToString())

}

}

private void ShowMsg()

{{

XtraMessageBox.Show(itsDeptEntity.DeptName)

}

private void simpleButton1_Click(object sender、EventArgs e)

{{

ShowMsg()

}

}

パブリッククラスDeptEntity

{{

パブリック文字列DeptName

{{

取得する

セットする

}

}

}

2、インターフェース設定

3、最終的なインターフェース効果