Hi Guys
I am having some troubles isolating the click event of the row selectors, mainly because I use RowSelectorNumberStyle.RowIndex, and the row index is a text element...
I have used a DrawFilter to remove the selector arrows.
I have already trapped the column header click with no problems using the following code on mouse down:Dim ThisUIElement As UIElementDim ThisHeader As ColumnHeaderThisUIElement = Grid.DisplayLayout.UIElement.ElementFromPoint(New Point(e.X, e.Y))If Not ThisUIElement Is Nothing Then ThisHeader = ThisUIElement.GetContext(GetType(ColumnHeader)) If Not ThisHeader Is Nothing Then *Code* End IfEnd If
This seems to pay no attention to whether I click the column header caption or not... Unfortunately, with the row selectors, clicking on the row index numbers makes the current UIElement a TextElement rather than RowSelectorUIElement
How can I isolate a click event on a row selector whether it is on the row index or not?
---------------------------------------------------------------------------- Also, is there any way to have the row selectors occupy their own column space, rather than overlap the first column in the grid?
Thanks in advance!
pkirsch said:How can I isolate a click event on a row selector whether it is on the row index or not?
The GetAncestor method will be helpful here. What you can do is get the ElementFromPoint just as you are doing. Check the type of the element. If it's already a RowSelectorUIElement, then you're done. If not, then you can call GetAncestor on it and pass in GetType(RowSelectorUIElement). This will walk up the elements parent chain through all of i's containing elements and return any RowSelectorUIElement in the chain. If it returns one, you know it was a RowSelector. If not, it will return Nothing.
pkirsch said:Also, is there any way to have the row selectors occupy their own column space, rather than overlap the first column in the grid?
I beleive you are looking for the RowSelectorHeaderStyle property.
Mike, you are the man. The GetAncestor method worked flawlessly and was very easy to implement since I only had to check 1 generation max ;)Thank you very much.
The RowSelectorHeaderStyle was indeed exactly what I was looking for!