2012-12-08 39 views
0

我有一個winform,從生物識別設備中提取日期時間信息,並以下面的格式顯示未綁定的datagridview上的信息。如何設置DatagridView值

S/N  Type Veri  Name  Datetime 
====  ==== ====  ====  ======== 
1   1  2   emp  2012/12/01 13:00 

How can I replace the Type=1 to "In", and Veri=2 to "FP"?? 

這是我目前的代碼。還有,我合併年/月/日時間的方式是否正確?

vRet = Form1.SBXPC1.GetAllGLogData(mMachineNumber, vTMachineNumber, vSEnrollNumber,  vSMachineNumber, vVerifyMode, vYear, vMonth, vDay, vHour, vMinute, vSecond) 
      If vRet = False Then Exit Do 
      vRet = Form1.SBXPC1.GetUserName1(mMachineNumber, vSEnrollNumber, vName) 
      If vRet = True And i <> 1 Then 
       DataGridView2.ColumnCount = 7 
       DataGridView2.Columns(0).Name = "S/N" 
       DataGridView2.Columns(1).Name = "DeviceID" 
       DataGridView2.Columns(2).Name = "Enroll" 
       DataGridView2.Columns(3).Name = "Name" 
       DataGridView2.Columns(4).Name = "DN" 
       DataGridView2.Columns(5).Name = "Veri" 
       DataGridView2.Columns(6).Name = "Datetime" 
      End If 
      Dim row As String() = New String() {i, vTMachineNumber, vSEnrollNumber, vName, vSMachineNumber, vVerifyMode, CStr(vYear) & "/" & (vMonth) & "/" & (vDay) & " " & (vHour) & ":" & (vMinute)} 
      DataGridView2.Rows.Add(row) 

回答

0

我會用立即如果:

Dim row As String() = New String() {i, vTMachineNumber, vSEnrollNumber, vName, vSMachineNumber, If(vVerifyMode = 2, "FP", ""), CStr(vYear) & "/" & (vMonth) & "/" & (vDay) & " " & (vHour) & ":" & (vMinute)} 
+1

I如果是deprected。 '如果(vVerifyMode = 2,「FP」,「」)'工作得很好 – Origin

+0

感謝您指出這一點,我沒有聽說過,實際上If運算符比IIf好很多。我看到If運算符是在Visual Studio 2008中引入的,你知道它是否需要某個.NET版本嗎? –

+0

謝謝你們。得到它的工作..很多在這裏學習.. – Bladefreak