This is a migrated thread and some comments may be shown as answers.

How to input values into RadGridView cells in a coded step

4 Answers 217 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 02 Feb 2015, 04:21 PM
Hi.
I would like to be able to simulate a user inputting values into the cells of a radGridView in a WPF application.
I have access to the grid itself within the coded step and can read the contents of each cell (view GridViewCell.TextBlockContent property).
What I would to do is set/input the text into the cell (as if the user had typed it in).
I want to do this in a coded step because the number of rows will vary and I want to input  a value into each row.
I have converted a recorded input step to code and can see that it uses TextBox.SetText(), but I can't see how I can do this for a cell?
Any help would be appreciated.
Thanks,
Mike.

4 Answers, 1 is accepted

Sort by
0
Ivaylo
Telerik team
answered on 05 Feb 2015, 01:55 PM
Hello Mike,

Let me do some clarification on the quote bellow:

"I have converted a recorded input step to code and can see that it uses TextBox.SetText(), but I can't see how I can do this for a cell?"

In a RadGridView, what you're editing is not actually the grid cell itself, but the textblock that has been placed within that cell. Keep in mind that a grid cell may contain virtually anything, text, an icon, a link, another grid, and so on.  The content of the cell changes radically between when the cell is in view mode versus editing mode. Examine the two attached screen shots, "Cell in view mode" and "Cell in edit mode". Notice when in view mode you have a TextBlock that is displaying the text. Versus in edit mode the content of the cell is changed radically. You now have a TextBoxView which is an editable type of UI element.

That is why when you convert the recorded step to code you see TextBox.SetText() method. So you can use the code generated by Test Studio.

Regards,
Ivaylo
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Mike
Top achievements
Rank 1
answered on 06 Feb 2015, 01:28 PM
Hi Ivaylo
Thanks for your response.
What I would like to do is iterate over the grid rows and "input" a value into each cell.
Could you provide some sample code to do this please?
Thanks,
Mike.
0
Madhu
Top achievements
Rank 1
answered on 09 Feb 2015, 09:43 PM
Hi Ivaylo,

I'm also in same situation with my silverlight application. Trying to enter some numbers in 'GridViewCell'. But no luck. See attachment.
Please provide a solution asap.

Thanks,
Madhu.
0
Ivaylo
Telerik team
answered on 11 Feb 2015, 08:34 AM
Hello Mike,

Here is a complete working example of selecting and editing cells in a Silverlight RadGridView. If you're dealing with a WPF application, the approach is virtually the same. The only difference is you launch the application instead of a browser, and you don't navigate to a website.

[TestMethod]
public void SilverlightDataGrid()
{
    Manager.Settings.Web.EnableSilverlight = true;
  
    Manager.LaunchNewBrowser();
    ActiveBrowser.NavigateTo("http://demos.telerik.com/silverlight/#GridView/DataSources");
  
    // Wait for the app to finish loading
    System.Threading.Thread.Sleep(5000);
    SilverlightApp sl_app = ActiveBrowser.SilverlightApps()[0];
  
    RadGridView rgv = sl_app.Find.ByAutomationId<RadGridView>("RadGridView1");
  
    IList<GridViewCell> gridCells = rgv.Rows[0].Cells;
  
    foreach (GridViewCell cell in gridCells)
    {
        cell.User.Click();
        Manager.Desktop.KeyBoard.TypeText("ABC 123");
        System.Threading.Thread.Sleep(500);
    }
  
    System.Threading.Thread.Sleep(5000);
}



@Madhu, this is answering your question as well, if you continue experiencing issues, please submit your own ticket/thread instead of interjecting to an existing one.

Regards,
Ivaylo
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Mike
Top achievements
Rank 1
Answers by
Ivaylo
Telerik team
Mike
Top achievements
Rank 1
Madhu
Top achievements
Rank 1
Share this question
or