Forum Discussion
7 Replies
Sort By
- murugans1011Regular Contributorto get cell value see obtain cell value for more info
http://support.smartbear.com/viewarticle/63250/ - mrezahoseiniContributori have enterd this code in my program, it didn't work."error log:"rows can not find"
bankingWinUI = Aliases.BankingWinUI;
tableLayoutPanel = bankingWinUI.frmUserSearch.tableLayoutPanel1;
Grid =tableLayoutPanel.entityDataGridView1.dgvMain;
var Driver = DDT.ExcelDriver("C:\\Add-Modireyate-Gorohha.xls", "Sheet1");
RowIndex = FindRow (Grid, 3, Driver.Value(0));
DDT.CloseDriver(Driver.Name);
if (RowIndex >= 0)
Grid.ClickCell (RowIndex, "F'E");
else
Log
.Error("Row was not found.");
function FindRow (Grid, ColumnId, Value)
{
for (var i=0; i<Grid.RowCount; i++)
if (Grid.Text.OleValue(i, ColumnId) == Value){
return i;
}
return -1;
}
- Ryan_MoranValued Contributor
function FindRow(Grid, ColumnId, Value){
for (var i=0; i < Grid.Rows.Count; i++){
if (Grid.wValue(i,ColumnId).OleValue == Value){
return i;
}
}
return -1;
} - mrezahoseiniContributorThanks for your reply
i enterd this code into my code, but the error has been
The error is : Unable to find the object wValue(0, ColumnName).
See Additional Information for details. 17:12:49 Normal
Is it ok if I ask you to help me again?
Thank you - Ryan_MoranValued ContributorIt's hard to tell with your aliasing, but is this a .Net application you are testing?
If so what is the ClrClassName of the object that you are passing to that function? - aminsaurabhOccasional ContributorHi , i have a VB.NET Application under test and the following code got the job done.
Function selectcell(Grid, Columname, Value) 'select the particular cell and click that cell
Dim i
Dim rowindex
rowindex = -1
For i = 0 To Grid.wRowCount-1
' Check the cell value in the specified column
If Grid.wValue(i, Columname) = Value Then
rowindex = i ' Row is found
End If
Next
if rowindex >=0 Then
Call Grid.ClickCell(rowindex, Columname)
Else
log.Error "value does not exist in the grid lookup","the value you are trying to select does not exist"
End If
End Function
hope this was helpful - sbkeenanFrequent ContributorHi Mina
I’m not sure if you have resolved your problem – if not, you might find that the grid control has a ‘FindRow’ method built-in. We use Developer Express grids in our application and I can use the FindRow function supplied. If you have such a method, you should be able to write something like:
var bankingWinUI = Aliases.BankingWinUI;
var tableLayoutPanel = bankingWinUI.frmUserSearch.tableLayoutPanel1;
var grid =tableLayoutPanel.entityDataGridView1.dgvMain;
var Driver = DDT.ExcelDriver("C:\\Add-Modireyate-Gorohha.xls", "Sheet1");
var rowIndex = grid.FindRow (3, Driver.Value(0));
DDT.CloseDriver(Driver.Name);
if (rowIndex >= 0)
grid.ClickCell (rowIndex, "F'E");
else
Log.Error("Row was not found.");
The above is based on your previously supplied code, but uses the built-in FindRow method, so there is no need to call a separate user-defined function in your code. The only other recommendation I would make is that rather than specifying the column index, you can use the column heading. I find that this serves two very useful purposes:
Sometimes grid columns are hidden from the end user so what looks like column 3 may actually be column 5!!
Using the column heading makes the code that much easier to follow and eliminates the need for commenting the fact that column 3 represents the <column name here> column.
Hope you find this helpful.
Regards
Stephen.
Related Content
- 10 years agoelfen_dark
- 11 years agokirk_bottomley
Recent Discussions
Check PopupMenu exists
Solved2 days agomfoster711- 3 days agosimonaferrara
- 3 days agomacheshmeh