This project is read-only.

Working with comboboxes inside datagrid

Nov 2, 2011 at 10:05 AM
Edited Nov 2, 2011 at 10:06 AM

Hi all,

  I am facing problem with getting comboboxes residing inside datagrid view. The scenario is as below,

When I click on header of the grid, it adds a new row containing combobox where I can select values.I am able to click on gridview header and it adds a new row containing combobx. But I am not sure how can I get those comboboxes inside datagrid.

I tried,

 AutomationElementCollection el= getDataTable(GridName).AutomationElement.FindAll(TreeScope.Children,Condition.TrueCondition);


but how would I get only combobxes from the AutomationElementCollection ??


Thanks in advance,

Cheers !

Nov 2, 2011 at 10:19 AM
Edited Nov 2, 2011 at 10:19 AM


first you should get the row, from the row you get the cells and from the cell you need get the Combobox

ist this a datagrid with custom items?

try this:



ListView listView = parent.Get<ListView>(SearchCriteria.ByAutomationID("id");

Now find the correct row

ListViewRow row = listView.Rows[index];

AutomationElementCollection coll = row.AutomationElement.FindAll(TreeScope.Descandents, new PropertyCondition(AutomationElement.ClassNameProperty, "add class name here");

ListViewCells cells = new ListViewCells(coll, listView.ActionListener, listView.Headers);

ListViewCell cell = cells["headername"];

ComboBox box = cell.Get<ComboBox>(SearchCriteria,ByControlType(ControlType.ComboBox));



=> done


Hope that helps









Nov 2, 2011 at 10:33 AM
Edited Nov 2, 2011 at 10:46 AM

Hi Throndorin,

Rows inside the datagrid are being identified as Tablerows, my code is as below.


TableRows rows = getAllRows(GridName);         // gets all the rows in datagrid

  foreach (TableRow row in rows)        {                           

row.Cells[index].Click();    // When I click on the rows, comboboxes appear on that row

[ Now could you tell me how'd I get the combobox? ]



And also my doubt is , when I find the table cell, I don't have any method cell.Get, I get only cell.getElement. this is the actual problem I am facing.

Nov 2, 2011 at 11:01 AM
Edited Nov 2, 2011 at 11:01 AM

have you tried the this part?


ListViewCell cell = row.Cells["headername"]; ComboBox box = cell.Get<ComboBox>(SearchCriteria,ByControlType(ControlType.ComboBox));
Nov 2, 2011 at 11:16 AM

Yes Throndorin,


 I have tried that part of code, when I use ListView the control doesn't get identified. The only way I got to identify it as TableRows and TableCells.

  I actually got all the rows and looping them so I can get the correct row as you mentioned. And I tried the way you suggested me like, cell.get<ComboBox> in my case it should be row.Cells[0].Get<ComboBox>, but I dont get row.cells[0].Get<Combobox> I get only row.cells[0].getElement() which returns automation element but not combobox.


Am I atleast following the proper way ? following is the code I actually have


foreach (TableRow r in rows)


   row.Cells[0].Get<ComboBox>(SearchCriterea.ByControlType(ControlType.ComboBox));  // I am not able to compile this line, it says no get method is available for this control.


Nov 2, 2011 at 11:30 AM

which version of White is referenced in your project?

I can build something like that without problems

Nov 2, 2011 at 11:39 AM

Oh I see, well I am using White_Bin_0.2.0, Do I need to update/ get latest copy ? I am confused now !

Nov 2, 2011 at 11:42 AM

I'm not sure

we are still use 0.19

if 0.21 shows the same problem it is a bug

Nov 2, 2011 at 12:19 PM

Oh well below is the error I get,


Error 2 'White.Core.UIItems.TableItems.TableRow' does not contain a definition for 'Get' and no extension method 'Get' accepting a first argument of type 'White.Core.UIItems.TableItems.TableRow' could be found (are you missing a using directive or an assembly reference?) C:\AutomationUtilities- With Main\AutomationUtilities\AutomationUtilities\GridHandler.cs 105 32 AutomationUtilities

 and the code is 


TableRows rows = getAllRows(GridName);       

int col;       

int.TryParse(ColumnNumber, out col);       

foreach (TableRow row in rows)        {           

ComboBox box = row.Get<ComboBox>(SearchCriteria.ByControlType(ControlType.ComboBox));       // This is the line that throws above mentioned error



when I use below line

TableCell cell = row.Cells[0];           

ComboBox box = cell.Get<ComboBox>(SearchCriteria.ByControlType(ControlType.ComboBox));


I get below error 

Error 2 'White.Core.UIItems.TableItems.TableCell' does not contain a definition for 'Get' and no extension method 'Get' accepting a first argument of type 'White.Core.UIItems.TableItems.TableCell' could be found (are you missing a using directive or an assembly reference?) C:\AutomationUtilities- With Main\AutomationUtilities\AutomationUtilities\SmartClientGridHandler.cs 105 33 AutomationUtilities

Nov 2, 2011 at 1:24 PM

in 0.21 the same problem!!!!! I have tried for some minutes

Nov 2, 2011 at 1:27 PM

try this Workaround:


AutomationElement element = cell.GetElement(SearchCriteria.ByControlType(ControlType.ComboBox));

ComboBox box = new ComboBox(element, cell.ActionListener);




Nov 2, 2011 at 1:27 PM

Yes I tried it too ! facing same problem in 0.21. I've no idea if I am missing something or it's actually a existing problem. 

Nov 2, 2011 at 2:00 PM

Thanks a lot Throndorin,

When I saw at first, comboboxes were being inserted into rows but when I spied them I found comboboxes are child of datagrid, but they are not really residing inside rows. the workaround worked well for me but still those two errors I get are keeping me confused. 


Cheers !

Nov 2, 2011 at 2:36 PM

Issue added: Issue11397