代码之家  ›  专栏  ›  技术社区  ›  Kyra

Devexpress LookupEdit不显示最后一行的选定行

  •  0
  • Kyra  · 技术社区  · 14 年前

    我正在使用 DevExpress.XtraEditors.LookUpEdit

    lookupedit.Properties.ForceInitialize() ' Force it to initialize
    lookupedit.Properties.PopulateColumns() ' Force the lookupedit to populate
       For i As Integer = 0 To tableData.Rows.Count - 1  ' Go through the information in it
          If lblClassVal.Text = tableData.Rows(i).Item(1).ToString() Then ' if the current row is equal to the value I want to select
              lookupedit.EditValue = i + 1 ' then I set the lookupedit value
          End If
       Next i
    lookupedit.Properties.Columns("class_id").Visible = False  ' set two columns to invisible
    lookupedit.Properties.Columns("active").Visible = False
    lookupedit.Properties.Columns("class_name").Caption = "Class Name" ' set the 3rd column to a better title
    

    现在lookupedit将显示选定的文本,除非我选择最后一行,即row number tableData.Rows.Count +1 当设置lookupedit时,它会将其设置为前一行,因为第一行无法显示。

    1 回复  |  直到 14 年前
        1
  •  0
  •   Kyra    14 年前

    因此DevExpress LookUpEdit不使用行号,而是使用LookUpEdit表中的ID列。因此,不要按行号选择它,而是将EditValue设置为要选择的行的ID号。所以不是:

    If lblClassVal.Text = tableData.Rows(i).Item(1).ToString() Then ' if the current row is equal to the value I want to select
       lookupedit.EditValue = i + 1 ' then I set the lookupedit value
    End If
    

    用途:

    If lblClassVal.Text = tableData.Rows(i).Item(1).ToString() Then ' if the current row is equal to the value I want to select
       lookupedit.EditValue = tableData.Rows(i).Item(0).ToString() ' Where Item(0) is my ID number column
    End If