51Testing软件测试论坛

标题: SwfTable,获取指定行(CurrentRow)的行号(RowNum)的方法 [打印本页]

作者: sbw317    时间: 2012-7-11 16:14
标题: SwfTable,获取指定行(CurrentRow)的行号(RowNum)的方法
在SwfTable中,我想获取【名称】(表格中的第1列)为【test123】的记录的当前行号。
请各位大大看一下,这种方法是不是太笨了,有没有更好一点的方法?

intRow=SwfWindow("XXX").SwfTable("XXX").RowCount

For i=0 to intRow
strRow = SwfWindow("XXX").SwfTable("XXX").GetCellData(i,1)
  If strRow="test123"  Then
       intRowNum = i
    Exit for
  End If
Next
作者: 450683057    时间: 2012-7-11 16:47
1.根据字段值,选中所在行,函数如下!
' 根据字段值选择所在的行
Function SelectRowByField(w_DataGridView , Field , FieldText)
'  Reporter.Filter = rfDisableAll
  For I = 0 to w_DataGridView.RowCount - 1
          If w_DataGridView.GetCellProperty(I,Field,"Value") = FieldText Then
                          w_DataGridView.SelectRow I
                          SelectRowByField = True
                    Exit Function
                  End If
  Next
'  Reporter.Filter = rfEnableAll  
  SelectRowByField  = False
End Function
RegisterUserFunc  "SwfTable","SelectRowByField","SelectRowByField"
2.通过  h=obj.GetROProperty("CurrentRow.Index") '获取当前行号。
作者: 450683057    时间: 2012-7-11 16:49
我也刚学QTP互相交流
MSN:hongxu.jiang12@hotmail.com(上班用)
qq:450683057




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2