Good morning,
I have a Ultragrid which has a combo box in it. When I record, the value will work with the SetCellData if it is correct. Some of our values have trailing spaces and some do not. I need to get the combo box from the cell. Then I can process the items to see if the specified value is available. If available I can select the value.
Can you tell me how to get the combo box object so I can work with it?
Regards,
Brian
That depends highly on how, where and when the combobox's gets it's data as well as what the combobox actually is. By default, I would say you should be able to use GetNAProperty to get either the cell's or the columns ValueList property, and look at it's ValueListItems. But it is also quite possible that the combobox is a customized editor that doesn't follow that methodology or place of storage for it's data, or that it only populates the combobox on dropdown, and the valuelists are empty prior to that. For the later you can activate the cell, then PerformAction gridEnterEditModeAndDropdown, then try to get the value of the valuelists. If none of those work, I would suggest contacting your developer and learning more about this particular instance of combobox itself.
As to QTP getting ahold of the specific combobox, in most scenarios the combobox is an editor component and not really a control. In which case QTP has no knowledge of it, as it only interacts with objects that inherit form System.Windows.Forms.Control.
Hi Michael,
Could you possible provide and example of the code to get both the cell and column value list items?
Thank you,
It's been a while, but in looking again the Cell should have a ValueListResolved property that should be viable to use if the ValueList is set on either the Cell or the Column, again it may be necessary to drop down the cell before doing this via PerformAction that I mentioned earlier.
SET grid = SwfWindow("Form1").SwfTable("ultraGrid1")iRow = 2sCol = "VL_Column"sValListItems = "Rows[" + CSTR(iRow) + "].Cells[" + sCol + "].ValueListResolved.ValueListItems"iVLItemsCnt = grid.GetNAProperty(sValListItems + ".Count")sListValues = ""For x = 0 to iVLItemsCnt - 1 sListValues = sListValues + grid.GetNAProperty(sValListItems + "["+cstr(x)+"]") +vbCRLFNextmsgbox sListValues
Hi Mike,
Here is the code that I used:
'Activate the cell on the table with the combo and see if we can get the count of the list itemsSet objectTable = SwfWindow("SwfWindow").SwfTable("MyTable")rowNumberHeader = 0assignedColNumber = 0colKeyTextInfo = CommonTMSGetHeaderKey(objectTable, rowNumberHeader, assignedColNumber)
objectTable.ActivateCell 0, 0iRow = 1sCol = colKeyTextInfosValListItems = "Rows[" + CSTR(iRow) + "].Cells[" + sCol + "].ValueListResolved.ValueListItems"
iVLItemsCnt = objectTable.GetNAProperty(sValListItems & ".Count")sListValues = ""
For x = 0 to iVLItemsCnt - 1 sListValues = sListValues + objectTable.GetNAProperty(sValListItems + "["+cstr(x)+"]") +vbCRLFNextmsgbox sListValues
When I run the script, I get the following error message:
Exception is thrown by the control with the following Error Message:\nIndex was outside the bounds of the array.
Line (13): "iVLItemsCnt = objectTable.GetNAProperty(sValListItems & ".Count")".
Any suggestion on what I might have missed on this?
Thanks,
HI Mike,
I missed a couple of items on the code which needed to be update. The "+" needed to be "&" in order to get value to come out. I am geting the long description value but I also need the short description. In other combo boxes as and example the displayed value is "" and the description is "None". The two values are needed.
Here is the updated code.
objectTable.ActivateCell 0, 0iRow = 0sCol = colKeyTextInfosValListItems = "Rows[" + CSTR(iRow) + "].Cells[" & sCol & "].ValueListResolved.ValueListItems"
For x = 0 to iVLItemsCnt - 1 sListValues = sListValues + objectTable.GetNAProperty(sValListItems & "["& cstr(x) & "]") & vbCRLFNextmsgbox sListValues
Thanks for your help,
Hi Brian,
I am not sure of how you mean with your distinction between short description and long description as those are not properties of a ValueListItem, and your developer may be getting them from any number of places. That being said the members of a ValueListItem can be found in our online help here.
I would try both DisplayText and DataValue as these are most likely.
So in code either :
sListValues = sListValues + objectTable.GetNAProperty(sValListItems & "["& cstr(x) & "].DataValue") & vbCRLF
or
sListValues = sListValues + objectTable.GetNAProperty(sValListItems & "["& cstr(x) & "].DisplayText") & vbCRLF
Hi Michael.
I tried to DataValue: sListDispValues = sListDispValues & objectTable.GetNAProperty(sValListItems & "["& cstr(x) & "].DataValue") & vbCRLF
but I get the following error:
Type 'Summit.Framework.View.DDItem' in Assembly 'Framework, Version=5.30.9245.1139, Culture=neutral, PublicKeyToken=1984b01ba11e2fd5' is not marked as serializable.
Line (19): "sListDispValues = sListDispValues & objectTable.GetNAProperty(sValListItems & "["& cstr(x) & "].DataValue") & vbCRLF".
The value returned by the original code: sListValues = sListValues & objectTable.GetNAProperty(sValListItems & "["& cstr(x) & "]") & vbCRLF
And the new for DisplayText: sListTextValues = sListTextValues & objectTable.GetNAProperty(sValListItems & "["& cstr(x) & "].DisplayText") & vbCRLF
Both return the value is the list here are some examples
Displayed Value after selection
Displayed Description in List
"" or Empty String value
None
SECID
Security ID
ABI
ABI(Italy)
I need to select by the Displayed Values for some columns and the Description for others. The text is coming from the database and is dynamic. Sometimes we get extra spaces which is why I need to get the value.
In other combo elements I get a singe value such as "";None, or SECID:SecurityID.
Let me know if this clears things up.