The very first column, including the header, in my grid control has an embedded check box. How do I get the state of whether or not this is checked, and how do I set the check box state?
Right now I am using DoubleClickHeader 0, "CheckedColumn" to get the mouse to move to the center of the column header. Then I grab mouse coordinates and apply a mouse click. However this is not a very good way long term, nor do I know if I am setting the check box, or removing a check state alread set.
Thanks
What version of NetAdvantage are you using?
The reason I ask is prior to 9.1 to embed a checkbox into a header required you to alter the base functionality grid with at least a draw filter, but likely it was done with a creation filter. This level of modifications to the grid are not, and simply cannot be supported inherently in TestAdvantage. That being said, if you are using 9.1 or newer and utilizing the feature built in NetAdvantage 9.1 then there are two actions that you can use (SetColumnHeaderCheckState, GetColumnHeaderCheckState), otherwise you need to ask your developer where he saves the CheckState, as he created the customization, and then you should be able to use GetNAProperty to get the value.
Thanks for the quick response Mike. Currently using 2007 volume 1, we will be switching to 2008 volume 3 pretty soon - so sounds like I'll need to use GetNAProperty. I'll talk to the dev for the control.
I've had some difficulty navigating the API documentation online for NetAdvantage to understand which properties I need to access in the API to match the particular cell/column/header in my Grid control. For example, I might know that I need to get a cell value or header property, but I have a difficult time translating that into the online documentation. Can you offer any guidance here? Would using a tool that I have seen mentioned on here such as the Windows Forms Spy help me understand this a little better?
Really appreciate your time,
James
Navigating the API's of controls with the complexity of the grid can be quite difficult. In for a rule of thumb, it depends on what information you have, and what information do you want to get, and of course that can be drastically modified by how complex your grid is. If it's heirarchical that adds a signifigant level of complexity to it.
A general concept you should keep in mind, if the word is plural it is likely a collection. Most of our collections, if not all should have a Count property with you can use to get the sum total of all of those in the collection and therefore you can then loop through them. Also, if it is a collection, it will give you a means to get at a single one, such as Rows[0] will get you the first row.
Things to know, the two main entry points that you will likely use the most are:
From Rows you can get the Cells, from the Cell you can get the value, or the column.
From DisplayLayout you get the Bands (which in a flat grid still has one which is Bands[0]), from the Band you can get the columns, from the column you can functional and display based properties of the column, as well as the header, but you cannot get the cells, and therefore not the value.
So you can do things like:
SET grid = SwfWindow("Form1").SwfTable("ultraGrid1")
cellValue = grid.GetNAProperty("Rows[0].Cells[0].Value")
colCaption = grid.GetNAProperty("Rows[0].Cells[0].Column.Header.Caption")
colCaption = grid.GetNAProperty("DisplayLayout.Bands[0].Columns[0].Header.Caption")
For heirarchical data, you need to keep in mind that for the purpose of the grid, that it is possible to have multiple bands at the same level (except for the top one). Also that even though all the Rows of a childband are in one collection like a table. In the case of a grid they are accessed as sub collections of their parent.
cellValue = grid.GetNAProperty("Rows[0].ChildBands[0].Rows[0].Cells[0].Value")
Here is an example for looping through a collection. Note the use of CSTR() which is a VBscript function via QuickTestProfessional used to make sure the object are all the correct type, in this case string. Also note that all collections are zero based, but their counts are not. So a collection with three objects, indexes are 0,1,2 and therefore you need to adjust you loop to correspond to that.
strColKeys = ""colCount = grid.GetNAProperty("DisplayLayout.Bands[0].Columns.Count")For index = 0 to colCount - 1 strColKeys = strColKeys + CSTR(grid.GetNAProperty("DisplayLayout.Bands[0].Columns["+CSTR(index)+"].Key")) + vbcrlfNextmsgbox strColKeys
I hope this gives you enough basis to work from,