2010-07-23 108 views
0

我正在使用DevExpress.XtraEditors.LookUpEdit來顯示有關可用類的信息。目前它有3列。除了當我將editValue設置爲最後一行時,lookupedit工作正常。如果editvalue被設置爲除最後一行以外的任何行,則當lookupedit設置爲最後一行時不顯示任何內容,則當lookupedit未打開時顯示所選行。目前我:Devexpress 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時,它將它設置爲上一行,我希望第一行無法顯示。

回答

0

好的我解決了這個問題。以防萬一別人有這個問題我會留下問題。

所以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 
相關問題