Only the display item should be displayed in the drop-down list.

I ultracombo collection to ultracombo and I specified the value member and display member . There are many columns in the collections. Now I need to show only one column located on the display, and one column assigned by value member . Now I see that all columns in collections are displayed as multicolumn .

//Code

  cboUltra.ValueMember = "LookupValue" cboUltra.DisplayMember = "LookupValueDescription" cboUltra.DataSource = LoadLookupDetails(Field.LookUpCode) UltraGridRow.Cells("FieldValue").ValueList = cboUltra 

How can i achieve this?

+4
source share
3 answers

UltraCombo will automatically generate all columns. You can either add the desired column before setting the data source and set cboUltra.DisplayLayout.NewColumnLoadStyle to NewColumnLoadStyle.Hide, or you can hide all the columns except the columns you want after creating them by going through them to the InitializeLayout event and all of them will be hidden, except for those that you want.

You can also watch UltraComboEditor , as it displays only one column. Regardless of whether these are options for you, you will depend on what features you need with the drop-down list.

+2
source

In C # you can try the following: -> Add "ultraCombo1" since you are an ultra combo ... when loading a form, try the following code:

  private void Form1_Load(object sender, EventArgs e) { // Fill data in ultracombo datasource DataTable dtt = new DataTable(); dtt.Columns.Add("ID", typeof(int)); dtt.Columns.Add("Name", typeof(string)); dtt.Columns.Add("Age", typeof(int)); dtt.Columns.Add("Address", typeof(string)); dtt.Columns.Add("Sex", typeof(string)); dtt.Rows.Add(new object[] {1,"Name1",20,"Address 1","Male"}); dtt.Rows.Add(new object[] { 2, "Name2", 21, "Address 2", "Male" }); dtt.Rows.Add(new object[] { 3, "Name3", 22, "Address 3", "Female" }); dtt.Rows.Add(new object[] { 4, "Name4", 23, "Address 4", "Male" }); dtt.Rows.Add(new object[] { 5, "Name5", 24, "Address 5", "Female" }); ultraCombo1.DataSource = dtt; ultraCombo1.DataBind(); //--------------------------------- // hide all but show "ID" and "Name" only ultraCombo1.ValueMember = "ID"; ultraCombo1.DisplayMember = "Name"; for (int i = 0; i < ultraCombo1.Rows.Band.Columns.Count; i++) { ultraCombo1.Rows.Band.Columns[i].Hidden = true; } ultraCombo1.Rows.Band.Columns["ID"].Hidden = false; ultraCombo1.Rows.Band.Columns["Name"].Hidden = false; } 

The ultrafine plant will be populated with a member of the "ID" value and only "Name" will be displayed.

+7
source

Here is an extension method that will hide all columns except the DisplayMember column.

 <Extension()> Public Sub ShowOnlyDisplayMemberColumn(this As UltraCombo) Dim columnName As String = this.DisplayMember For Each band As UltraGridBand In this.DisplayLayout.Bands For i As Integer = 0 To band.Columns.Count - 1 Dim column As UltraGridColumn = band.Columns(i) If (column.Key = columnName) Then column.Hidden = False column.Width = this.Width Else column.Hidden = True End If Next Next End Sub 
0
source

Source: https://habr.com/ru/post/1483756/


All Articles