Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Report Control
  New Posts New Posts RSS Feed - SOLVED: Left column
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

SOLVED: Left column

 Post Reply Post Reply
Author
Message
ElvisM View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 October 2006
Location: Venezuela
Status: Offline
Points: 129
Post Options Post Options   Thanks (0) Thanks(0)   Quote ElvisM Quote  Post ReplyReply Direct Link To This Post Topic: SOLVED: Left column
    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
Back to Top
Aaron View Drop Down
Senior Member
Senior Member
Avatar

Joined: 29 January 2008
Status: Offline
Points: 2192
Post Options Post Options   Thanks (0) Thanks(0)   Quote Aaron Quote  Post ReplyReply Direct Link To This Post 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....
Back to Top
ElvisM View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 October 2006
Location: Venezuela
Status: Offline
Points: 129
Post Options Post Options   Thanks (0) Thanks(0)   Quote ElvisM Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
ijwelch View Drop Down
Senior Member
Senior Member


Joined: 20 June 2006
Status: Offline
Points: 262
Post Options Post Options   Thanks (0) Thanks(0)   Quote ijwelch Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Aaron View Drop Down
Senior Member
Senior Member
Avatar

Joined: 29 January 2008
Status: Offline
Points: 2192
Post Options Post Options   Thanks (0) Thanks(0)   Quote Aaron Quote  Post ReplyReply Direct Link To This Post 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 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....
Back to Top
ijwelch View Drop Down
Senior Member
Senior Member


Joined: 20 June 2006
Status: Offline
Points: 262
Post Options Post Options   Thanks (0) Thanks(0)   Quote ijwelch Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
Aaron View Drop Down
Senior Member
Senior Member
Avatar

Joined: 29 January 2008
Status: Offline
Points: 2192
Post Options Post Options   Thanks (0) Thanks(0)   Quote Aaron Quote  Post ReplyReply Direct Link To This Post 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....
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.203 seconds.