SOLVED: Left column |
Post Reply |
Author | |
ElvisM
Senior Member Joined: 12 October 2006 Location: Venezuela Status: Offline Points: 129 |
Post Options
Thanks(0)
Posted: 04 June 2008 at 6:08pm |
Hi friends.
There's a way to know the left columns index in a reportcontrol?
I'm using the Focusedcolumn property, but it fails. Maybe because I'm using frozencolumns and allrowselected.
regards. |
|
Product: Xtreme SuitePro (ActiveX) version 17.2
Platform: Windows 10 64bits Language: Visual Basic 2015 |
|
Aaron
Senior Member Joined: 29 January 2008 Status: Offline Points: 2192 |
Post Options
Thanks(0)
|
Hi,
Did you set wndReportControl.FocusSubItems = true ?
If you mean the first visible column: see the sample in your other post
|
|
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2 Language: Visual Basic 6.0 Zero replies is not an option.... |
|
ElvisM
Senior Member Joined: 12 October 2006 Location: Venezuela Status: Offline Points: 129 |
Post Options
Thanks(0)
|
Well, my really question is: There is a way to know the left column's index in the report control?. Not the column's index where is the focus... I don't know if you understandme.
When the user moves the horizontal scrollbar the report control changes the columns, and maybe the focused columns hides of the reportcontrol. But I wanna know the left columns index in every moment that the user moves the horizontal scrollbar...
Regards and excuseme by my bad english.
|
|
ijwelch
Senior Member Joined: 20 June 2006 Status: Offline Points: 262 |
Post Options
Thanks(0)
|
Try something like this (VB6) which seems to work regardless of column order:
Private Function GetFirstVisibleColumnIndex(Optional bFullyVisible As Boolean = True) As Long Dim i As Long Dim lColumnCount As Long Dim lLeft As Long Dim lRight As Long Dim lTop As Long Dim lBottom As Long Dim lLeftmostIndex As Long Dim lLeftmostLeft As Long If rpt.Rows.Count Then lColumnCount = rpt.Columns.Count - 1 lLeftmostLeft = 999999 For i = 0 To lColumnCount rpt.Rows(1).GetItemRect rpt.Rows(1).Record.Item(i), lLeft, lTop, lRight, lBottom If lRight > 0 Then 'it's at least partially visible If bFullyVisible Then If (lRight - lLeft) >= rpt.Columns.Column(i).Width Then 'it's fully visible If lLeft < lLeftmostLeft Then lLeftmostIndex = i lLeftmostLeft = lLeft End If End If Else If lLeft < lLeftmostLeft Then lLeftmostIndex = i lLeftmostLeft = lLeft End If End If End If Next GetFirstVisibleColumnIndex = lLeftmostIndex Else GetFirstVisibleColumnIndex = -1 End If End Function I've only just put this together so be careful |
|
Aaron
Senior Member Joined: 29 January 2008 Status: Offline Points: 2192 |
Post Options
Thanks(0)
|
Hi Ian,
Elvis did a post Scrollbar Event and I made a sample for this and I included simular what did (well almost simular)
Private Function GetFirstVisibleColumn()
Dim i As Integer Dim l As Long Dim t As Long Dim r As Long Dim b As Long For i = 0 To wndReportControlData.Columns.Count - 1 wndReportControlData.Rows(wndReportControlData.FocusedRow.Index).GetItemRect wndReportControlData.FocusedRow.record(i), l, t, r, b If l > 0 Then GetFirstVisibleColumn = i - 1 'return column index Exit Function End If Next i End Function It's a little bit cheating but it works
|
|
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2 Language: Visual Basic 6.0 Zero replies is not an option.... |
|
ijwelch
Senior Member Joined: 20 June 2006 Status: Offline Points: 262 |
Post Options
Thanks(0)
|
Yeah, your code works provided the user hasn't moved columns into different positions.
Also, the Left parameter will contain 0 when horizontal scrollbar is fully left (so your 'If l > 0 then' line will fail and the function return zero by default). Anyway, I think CJ need to change the GetItemRect call to return negative values as opposed to zeros when item is not in view. |
|
Aaron
Senior Member Joined: 29 January 2008 Status: Offline Points: 2192 |
Post Options
Thanks(0)
|
Hi,
Yes you are right about the moved columns, but Elvis can't move the position of the columns because of the labels at the top.
But it's nice to have your code when columns are going to be moved
Thanks
|
|
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2 Language: Visual Basic 6.0 Zero replies is not an option.... |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |