devexpress

[c#, devexpress] ComboBoxEditor에 Class 데이터 넣고 사용하기

퐁퐁 2020. 7. 27. 14:56

Ex)

 

public class DataSample

{

    int num { get; set; }

    string data = { get; set; }

    public override string ToString() 

    {
        return data; 
    }

}

 

위의 class를 cbobobox에 item add 해주면 자동으로 ToString()을 override한 data항목이 표출되고

 

DataSample sample = combobox1.SelectedItem as DataSample; 이렇게 사용하면 데이터를 읽어올 수 있다.

 

위에는 int, string 두개의 항목만 넣었지만 다수의 항목을 넣고 사용할 수 있다.