LookUpEdit.Properties.NullText 를 통하여 Null 값을 나타내는 텍스트를 가져 오거나 설정할 수 있습니다.
public class CityInfo
{
public int ID { get; set; }
public string City { get; set; }
public string Country { get; set; }
public string Region { get; set; }
}
List<Person> Persons = new List<Person>();
List<CityInfo> Cities = new List<CityInfo>();
CreateData();
LookUpEdit lookUpEdit = new LookUpEdit();
lookUpEdit.Parent = this;
lookUpEdit.Location = new System.Drawing.Point(198,78);
lookUpEdit.Size = new System.Drawing.Size(199,20);
lookUpEdit.DataBindings.Add(new Binding("EditValue", Persons, "CityID"));
lookUpEdit.Properties.DataSource = Cities;
lookUpEdit.Properties.ValueMember = "ID";
lookUpEdit.Properties.DisplayMember = "City";
lookUpEdit.Properties.PopulateColumns();+
lookUpEdit.Properties.NullText = "NULL TEXT 입니다.";
lookUpEdit.CustomDisplayText += LookUpEdit_CustomDisplayText;
private void CreateData()
{
Cities.Add(new CityInfo() { ID = 0, City= "Barquisimeto", Country= "Venezuela", Region="Lara" });
Cities.Add(new CityInfo() { ID = 1, City = "Rio de Janeiro", Country = "Brazil", Region = "RJ" });
Cities.Add(new CityInfo() { ID = 2, City = "Cunewalde", Country = "Germany", Region = "" });
Cities.Add(new CityInfo() { ID = 3, City = "Madrid", Country = "Spain", Region = "" });
Cities.Add(new CityInfo() { ID = 4, City = "Charleroi", Country = "Belgium", Region = "" });
Cities.Add(new CityInfo() { ID = 5, City = "Sao Paulo", Country = "Brazil", Region = "SP" });
}
private void LookUpEdit_CustomDisplayText(object sender, DevExpress.XtraEditors.Controls.CustomDisplayTextEventArgs e)
{
LookUpEdit lookUpEdit = sender as LookUpEdit;
CityInfo city = lookUpEdit.Properties.GetDataSourceRowByKeyValue(e.Value) as CityInfo;
if(city!=null)
{
e.DisplayText = (sender as LookUpEdit).Properties.NullText;
}
}
728x90
'C# > DevExpress' 카테고리의 다른 글
DevExpress / Winform GridView에서 마우스 우클릭 시 달력을 출력하기. (1) | 2019.04.16 |
---|---|
DevExpress / Winform CheckedListBoxItem 컨트롤 추가하기. (0) | 2019.04.15 |
DevExpress / Winform LookUpEdit 컨트롤 추가하기. (0) | 2019.04.15 |
DevExpress / Winform CheckEdit 컨트롤에서 Indeterminate 값 추가하기. (0) | 2019.04.14 |
DevExpress / Winform CheckEdit 컨트롤 추가하기. (0) | 2019.04.14 |
댓글