Print Page | Close Window

SOLVED: Left column

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Report Control
Forum Description: Topics Related to Codejock Report Control
URL: http://forum.codejock.com/forum_posts.asp?TID=10912
Printed Date: 10 November 2024 at 8:51am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: SOLVED: Left column
Posted By: ElvisM
Subject: SOLVED: Left column
Date 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



Replies:
Posted By: Aaron
Date Posted: 05 June 2008 at 2:23am
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....


Posted By: ElvisM
Date Posted: 06 June 2008 at 11:15am

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.


Posted By: ijwelch
Date Posted: 06 June 2008 at 11:29pm
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


Posted By: Aaron
Date Posted: 07 June 2008 at 2:29am
Originally posted by ijwelch ijwelch wrote:

Try something like this (VB6) which seems to work regardless of column order:

I've only just put this together so be careful
 
Hi Ian,
 
Elvis did a post  https://forum.codejock.com/forum_posts.asp?TID=10894 - 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....


Posted By: ijwelch
Date Posted: 07 June 2008 at 4:37am
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.


Posted By: Aaron
Date Posted: 07 June 2008 at 5:46am
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....



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net