I am able to get the visible rows in the grid, but how do I get the visible columns? I am only interested in the columns that are visible in the active scroll region, not anthing that is out of view.
Hi Torrey. I put a debug.print into my loop through the visible header objects and all I ever get is group headers, never column headers. See the screencap below:
Testing out your code, I see it behaves exactly as you described. Although, I think you over complicated my previous snippet. Try replacing your section of code with the snippet below.
Dim csr As ColScrollRegion = Me.ultraGrid1.ActiveColScrollRegion For Each vh As VisibleHeader In csr.VisibleHeaders MessageBox.Show(vh.Header.Caption) Next
When you run the snippet in your application it should pop up a message box with the column name like the screen capture I posted. Inside the For..Next block you can place your code for the processing that needs done based on the visible columns.
I put in some debug code and all I ever get is Group Headers. I never get column headers. Here's The code I am using to get the visible columns. The formatting looks bad. You might have to paste it into a code window for readability.
grdGrid.ActiveColScrollRegion.VisibleHeaders
HeaderBase = objVisibleHeader.Header
Then
(objHeader, GroupHeader)
objGroupHeader.Group.Columns
UltraGridCell = e.Row.Cells(objUltraGridColumn.Key)
'make sure the cell is not hidden...
'make sure the cell is visible on the screen...
'this is definitely a grid cell that is visible on the screen...
If
Next
rehemann said: I tried using your suggestion. The VisibleHeaders seem to be GroupHeaders. From that I have to get all the columns in the group and loop through them, checking the GetUIElement on each of them as I loop. This works, but it seems like there should be a more efficient way to get the visible columns. Am I missing something?
I tried using your suggestion. The VisibleHeaders seem to be GroupHeaders. From that I have to get all the columns in the group and loop through them, checking the GetUIElement on each of them as I loop. This works, but it seems like there should be a more efficient way to get the visible columns. Am I missing something?
Are you able to post a code snippet of how you've integrated my suggestion, along with the event or method you used?
When I added groups to my own test and ran the code I previously posted it didn't pull group headers, it pulled actual columns that were visible as before. To be extra through I'll put a screen capture below of what my test looked like.
Note: If the image appears cutoff above, just click on it. It'll navigate to the image in a new window.
Hi Dave.
I saw that code and modeled my code after it. Unfortunately, it seems like I have to work my way down through visible headers, headers, groups and columns before I can get the column's key and see if the cell has a UIElement.
I am using the InitializeRow event of the grid and trying to optimize the code. My app uses that event heavily and the grid has gotten a little sticky. I was hoping to find a Columns collection on the VisibleScrollRegion, but this will work for now.
Thanks!
Rich