【问题标题】:Devexpress LookupEdit is not displaying the selected row for the last rowDevexpress LookupEdit 未显示最后一行的选定行
【发布时间】:2010-07-23 15:15:14
【问题描述】:

我正在使用DevExpress.XtraEditors.LookUpEdit 来显示有关可用课程的信息。目前它有3列。除非我将 editValue 设置为最后一行,否则查找编辑工作正常。当editvalue设置为除最后一行之外的任何行时,当lookupedit尚未打开时,它会显示选定的行,而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 显示选定的文本,除非我选择最后一行,行号tableData.Rows.Count,然后什么都不显示。然而,当我打印它们的值时它们是正确的,当我在设置查找编辑时删除+1 时,它会将其设置为上一行,我希望第一行无法显示。

【问题讨论】:

    标签: vb.net devexpress


    【解决方案1】:

    好的,我解决了这个问题。以防万一其他人遇到这个问题,我会留下这个问题。

    所以 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
    

    【讨论】:

      猜你喜欢
      • 2011-01-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-06
      • 2011-04-06
      • 1970-01-01
      • 2014-02-02
      • 1970-01-01
      相关资源
      最近更新 更多