簡體   English   中英

Devexpress LookupEdit沒有顯示最后一行的選定行

[英]Devexpress LookupEdit is not displaying the selected row for the last row

我正在使用DevExpress.XtraEditors.LookUpEdit來顯示有關可用類的信息。 目前它有3列。 除了將editValue設置為最后一行時,lookupedit正常運行。 當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然后什么也不顯示。 但是,當我打印這些值時,它們是正確的;當我在設置lookupedit時刪除+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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM