2010-07-23 6 views
0

DevExpress.XtraEditors.LookUpEdit을 사용하여 사용 가능한 클래스에 대한 정보를 표시합니다. 현재 3 개의 열이 있습니다. lookupedit은 editValue를 마지막 행으로 설정하는 경우를 제외하고는 완벽하게 작동합니다. editvalue가 마지막 행 이외의 행으로 설정되면 조회 편집이 열리지 않을 때 선택된 행을 표시하지만 조회가 마지막 행으로 설정된 경우에는 아무 것도 표시되지 않습니다. 현재 나는 : 다음 아무것도 표시되지 않습니다 마지막 행, 행 번호 tableData.Rows.Count를 선택하지 않으면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 선택한 텍스트를 표시합니다. 그러나 정확한 값을 인쇄 할 때 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 
관련 문제