Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Report Control
  New Posts New Posts RSS Feed - [SOLVED] Where am I wrong now? (selectionbycolumn)
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

[SOLVED] Where am I wrong now? (selectionbycolumn)

 Post Reply Post Reply
Author
Message
Albert1 View Drop Down
Groupie
Groupie
Avatar

Joined: 01 February 2007
Location: Italy
Status: Offline
Points: 66
Post Options Post Options   Thanks (0) Thanks(0)   Quote Albert1 Quote  Post ReplyReply Direct Link To This Post Topic: [SOLVED] Where am I wrong now? (selectionbycolumn)
    Posted: 05 October 2010 at 3:37am
I am looking for substitute the "old" tdbgrid/vsflex with CJ ReportControl but, for each feature I resolve, two problems raise...
 
The last one:
 
In a new form, insert a ReportControl and paste this code:

Option Explicit
Private Sub Form_Load()
Dim i As Integer, j As Integer
    Width = 7200
    Height = 4500
    With ReportControl
        For i = 0 To 5
            .Columns.Add i, "Col " & Chr$(65 + i), 150, False
        Next i
   
        For i = 0 To 20
            With .Records.Add
                For j = 0 To 5
                    .AddItem Chr$(65 + j)
                Next j
            End With
        Next i
        .Populate
    End With
End Sub
Private Sub Form_Resize()
    ReportControl.Move 0, 0, ScaleWidth, ScaleHeight
End Sub
Private Sub ReportControl_MouseDown(Button As Integer, Shift As Integer, x As Long, y As Long)
    If ReportControl.HitTest(x, y).ht = xtpHitTestReportArea Then
        Debug.Print "HitTest: ReportArea"
    ElseIf ReportControl.HitTest(x, y).ht = xtpHitTestUnknown Then
        Debug.Print "HitTest: Unknown"
    End If
End Sub
 
Run it. As you can see you can click the column A, B or C (the debug window states you are in the ReportArea).
Now, use the mouse and the horizontal scrollbar to show columns D,E and F. Click over the report control. You cannot select nothing (the debug window states you are in a Unknown Area, i.e. "no part of the ReportControl is at the given X and Y coordinates").
 
Set full screen and you can see you can select what you want.
 
This is a very basic grid behaviour. The basic grid included in VB about 15 years ago did this the corect way.
 
Am I the only one that use this or am I not able to understand this control?
TY
 
Product: Xtreme SuitePro (ActiveX) version 13.4.1 / 16.3.0

Platform: Windows Vista (32bit) - SP 2

Language: Visual Basic 6.0 (SP6)

Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1354
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 05 October 2010 at 8:51am
Looks like a bug with AutoColumnSizing = True when there are no auto-sizable columns.

Try putting .AutoColumnSizing = False in your Form_Load event immediately before you add your columns.

Also, please open a support ticket at https://support.codejock.com so that there is a chance that this will be fixed for the next release.

If Aaron is reading - perhaps you could add this to your bug list?

Thanks.

Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6

Back to Top
Albert1 View Drop Down
Groupie
Groupie
Avatar

Joined: 01 February 2007
Location: Italy
Status: Offline
Points: 66
Post Options Post Options   Thanks (0) Thanks(0)   Quote Albert1 Quote  Post ReplyReply Direct Link To This Post Posted: 05 October 2010 at 9:59am
Originally posted by jpbro jpbro wrote:

Looks like a bug with AutoColumnSizing = True when there are no auto-sizable columns.

Try putting .AutoColumnSizing = False in your Form_Load event immediately before you add your columns.
 
I dont know how you found this hack but ... it works! I have spent about one day over this.
 
I am trying to implement a way to select a column. In the past I did this with a single statement:
VsFlex.SelectionMode = flexSelectionByColumn
 
Now I need to use

       ReportControl .SetCustomDraw xtpCustomDrawItem
and the ReportControl_DrawItem event to paint the column items.
 
So with this code (working now)
 

With ReportControl
    If .HitTest(X, Y).ht = xtpHitTestReportArea Then
        Set .FocusedColumn = .HitTest(X, Y).Column
        Set .FocusedRow = .HitTest(X, Y).Row
    End If
End With
I can set the FocusedColumn and:

ReportControl_DrawItem()
        If Column.Index = rpt.FocusedColumn.Index Then
            Item.BackColor = vbRed
        Else
            Item.BackColor = vbWhite
        End If
End Sub
 
I reach the goal. But another bug is that I cannot use:

ReportControl.SelectionEnable = False
 
why the event will be raised only the second click ... The arrow keys are not fully working ...
 
Its a true neverending story ...
 
BTW: why there is no method to programmatically repaint the visible part of the ReportControl? Like the standard Visual Basic Refresh? (Redraw doesnt work).
 
Originally posted by jpbro jpbro wrote:

Also, please open a support ticket at https://support.codejock.com so that there is a chance that this will be fixed for the next release.
 
I did it this morning (for me) after this post.
 
Thank you!
 
Product: Xtreme SuitePro (ActiveX) version 13.4.1 / 16.3.0

Platform: Windows Vista (32bit) - SP 2

Language: Visual Basic 6.0 (SP6)

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 October 2010 at 2:36pm
Hi,
 
Focused column color:
 
With wndReportControl
        .PaintManager.ShadeSortColumn = True
        .PaintManager.ShadeSortColor = vbYellow
End With
 
 
 
 
 
Question:
 
I reach the goal. But another bug is that I cannot use:
ReportControl.SelectionEnable = False
 
why the event will be raised only the second click ... The arrow keys are not fully working ...
 
Answer:
What are you trying to accomplish?
 
 
Question:
BTW: why there is no method to programmatically repaint the visible part of the ReportControl? Like the standard Visual Basic Refresh? (Redraw doesnt work).
 
 
Answer:
  • Description

    Redraws the ReportControl

    Syntax

    Public Sub Redraw() 

    Remarks

    This method needs to be called any time you change a property in the ReportPaintManager.  This is required to redraw the visual changes that you make to the ReportControl.  For example, you would need to call the Redraw method after you change the grid line style.

  • Description

    Populates the ReportControl's with ReportRow collection with the data contained in the ReportRecords

    Syntax

    Public Sub Populate() 

    Remarks

     ReportRows(which are associated with a ReportRecord) will not be added to the ReportControl's view until the Populate method is called.

    The changes made to the GroupsOrder or SortOrder collections will only take effect after the Populate method is called.

    Populate can be called after each record is added, or after you are done adding all records.   If at any time you add or delete ReportRecords, the changes will not be visible until the Populate method is called.

     
So any changes made in Record Collection (adding or removing) you have to call .Populate otherwise changes don't show. Changing "Visual properties" need .Redraw method.
 
btw Do not hesitate to post your problems, there's always someone to help you a little further. I know ReportControl is an advanced control when you start using it, I know, I have been there Wink I believe it's a great control once you know how to use it (and problems are solved in near future...)
 
  
 
 
 
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
Albert1 View Drop Down
Groupie
Groupie
Avatar

Joined: 01 February 2007
Location: Italy
Status: Offline
Points: 66
Post Options Post Options   Thanks (0) Thanks(0)   Quote Albert1 Quote  Post ReplyReply Direct Link To This Post Posted: 06 October 2010 at 4:25am
Thank you Aaron for the suggestions,
 
Originally posted by Aaron Aaron wrote:

 
Focused column color:
 
With wndReportControl
        .PaintManager.ShadeSortColumn = True
        .PaintManager.ShadeSortColor = vbYellow
End With
 
 
I dont want the user can sort the columns. So I cannot use this approach.
I wish to substitute this "old" grid with a new themed grid:
 
 
The user can browse through models details using the mouse and/or the keyboard. There is allways a selected column. If the user wants, he can click on OK and the model is selected for the main form.
I can reach this with really little code using vsflex:
 
I set:

vsFlex.SelectionMode = flexSelectionByColumn
 
and only 1 event

Private Sub vsFlex_RowColChange()
    m_SelectedCol = vs.Col
End Sub
 
Thats all I need!!!
 
Further I can set:

vsFlex.FixedCols = 2
this way the first two column are really "fixed" and you cannot reach them with keyboard (this is asked by many people in this forum ...)
 
Originally posted by Aaron Aaron wrote:

Public Sub Redraw()
Remarks
This method needs to be called any time you change a property in the ReportPaintManager....
 
Public Sub Populate()
Remarks
ReportRows(which are associated with a ReportRecord) will not be added ...
 
I know this methods but they are not enough (if I am not wrong). Please check this code:
 

Option Explicit
Dim m_SelectedCol As Integer
Private Sub Form_Load()
Dim i As Integer, j As Integer
    Width = 7200
    Height = 4500
    With ReportControl
        .AutoColumnSizing = False
        .FocusSubItems = True
        .SetCustomDraw xtpCustomDrawItem
        For i = 0 To 5
            .Columns.Add i, "Col " & Chr$(65 + i), 150, False
        Next i
        For i = 0 To 20
            With .Records.Add
                For j = 0 To 5
                    .AddItem Chr$(65 + j)
                Next j
            End With
        Next i
        .Populate
    End With
End Sub
Private Sub Form_Resize()
    ReportControl.Move 0, 0, ScaleWidth, ScaleHeight
End Sub
Private Sub ReportControl_DrawItem(ByVal Row As XtremeReportControl.IReportRow, ByVal Column As XtremeReportControl.IReportColumn, ByVal Item As XtremeReportControl.IReportRecordItem, ByVal hDC As stdole.OLE_HANDLE, ByVal left As Long, ByVal top As Long, ByVal right As Long, ByVal bottom As Long, DoDefault As Boolean)
    If Column.Index = m_SelectedCol Then
        Item.BackColor = vbYellow
    Else
        Item.BackColor = vbWhite
    End If
End Sub
Private Sub ReportControl_FocusChanging(ByVal NewRow As XtremeReportControl.IReportRow, ByVal NewColumn As XtremeReportControl.IReportColumn, ByVal NewItem As XtremeReportControl.IReportRecordItem, Cancel As Boolean)
    m_SelectedCol = NewColumn.Index
End Sub
 
Run it. You can observe that:
1) The selected cell is "Col B", first row. Just curiosity. Why not "Col A"?
2) The event DrawItem is raised but nothing happens. Why?
3) Press the right arrow key. DrawItem set yellow in the first column?
From the help of DrawItem method:
Column
The ReportColumn that that contains the items that is currently being drawn.
So my code is valid.
4) Press again the right arrow key. DrawItem event set yellow to Col C (btw the focus is on Col D)
5) Press left and/or right arrow key ... You will see.
 
Remarks
If I had a Refresh method I could call when I want to do it, my problems were done? Or not?
 
In your opinion, should I have to open a ticket? I have subscription too.
 
Originally posted by Aaron Aaron wrote:

I know ReportControl is an advanced control when you start using it, I know, I have been there  I believe it's a great control once you know how to use it (and problems are solved in near future...)
Thank you Aaron. Btw I am not so noob ;). I can be noob with english language but not with VB language Wink. I dont fully agree with you about RC is a great control. I am using it for more than 2 years and I can do only simple works. I am not still able to fully substitute a TDBgrid and/or VSFlex. I hope for the next future (but it seems CJ wants to upgrade markup instead of RC Cry).
 
 
Product: Xtreme SuitePro (ActiveX) version 13.4.1 / 16.3.0

Platform: Windows Vista (32bit) - SP 2

Language: Visual Basic 6.0 (SP6)

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: 06 October 2010 at 5:14am
Hi,
 
Please one thing at a time Wink If this has been solved we will move to next "problem", OK?
 
Column selection problem:
 
  • Add columns that aren't sortable (if you don't want users to sort it of course)
  • Add wndReportControl.PaintManager.DrawSortTriangleAlways = False
  • Add wndReportControl.PaintManager.DrawSortTriangleStyle = xtpReportDrawSortTriangleNever 'Doesn't draw sort icon in column)

Add MouseDown event (this because FocusChanging isn't returning NewColumn and NewItem object GRRRRRR............. I tried with V13.4.1 Angry

Well to have a solution for you:
 
Private Sub wndReportControl_MouseDown(Button As Integer, Shift As Integer, x As Long, y As Long)
    Me.wndReportControl.SortOrder.DeleteAll
    Me.wndReportControl.SortOrder.Add Me.wndReportControl.HitTest(x, y).Column
End Sub
 
Well, if this helps you a little, we go to the next level Tongue
 
 
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
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: 06 October 2010 at 8:02am
Hi,
 
OK, I created test for you and keep this project to get answers for your other problems.
 
 
 
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
Albert1 View Drop Down
Groupie
Groupie
Avatar

Joined: 01 February 2007
Location: Italy
Status: Offline
Points: 66
Post Options Post Options   Thanks (0) Thanks(0)   Quote Albert1 Quote  Post ReplyReply Direct Link To This Post Posted: 06 October 2010 at 8:03am
Solved! Thumbs Up
 
Thanks Aaron. This is the result:
 
 
A "whole new world" with vista look Approve
 
This is the code I used for (if some1 needs it):


Private Sub Form_Load()
    With ReportControl
        .BorderStyle = xtpBorderThemedFrame
        .Move 120, 120
        .AllowColumnRemove = False
        .AllowColumnReorder = False
'        .AllowColumnResize = False
        .AllowColumnSort = False
        .AllowEdit = False
        .EnableMarkup = True
        .EditOnClick = False
        .FastDeselectMode = True
        .FocusSubItems = True
        .FullColumnScrolling = True
        .HeaderRowsAllowEdit = False
        .InitialSelectionEnable = True
        .MultipleSelection = False
        .RightToLeft = False
        .SelectionEnable = True
        .ShowHeader = True
        .ShowHeaderRows = False
        .ShowRowFocus = False
        .SetCustomDraw xtpCustomDrawItem
        With .PaintManager
            .ShowNonActiveInPlaceButton = False
            .ColumnStyle = xtpColumnShaded
            ' Excel 2007 colors
            .CaptionBackGradientColorLight = RGB(&HF9, &HFC, &HFD)
            .CaptionBackGradientColorDark = RGB(&HD3, &HDB, &HE9)
            .GridLineColor = RGB(&HD0, &HD7, &HE5)
            '
            .VerticalGridStyle = xtpGridSolid
            .ColumnHotGradientColorDark = .CaptionBackGradientColorDark
            .ColumnHotGradientColorLight = .CaptionBackGradientColorLight
            .ColumnPushedGradientColorDark = .ColumnHotGradientColorLight
            .ColumnPushedGradientColorLight = .ColumnHotGradientColorDark
            .InvertColumnOnClick = False
            .FreezeColsDividerStyle = xtpReportFreezeColsDividerHeader
            .FixedRowHeight = False
            .HideSelection = True
            .GrayIfDisable = False
            .ForceDynamicMarkupForCell = True
            ' .CaptionFont = gFontName
            ' .TextFont = gFontName
        End With
        '
        .Redraw
    End With

    With ReportControl
        .AutoColumnSizing = False   ' to resolve bug
        .SelectionEnable = False
        .PaintManager.ShadeSortColumn = True
        .PaintManager.ShadeSortColor = RGB(&HBF, &HDB, &HFF)
        .PaintManager.DrawSortTriangleAlways = False
        .PaintManager.DrawSortTriangleStyle = xtpReportDrawSortTriangleNever    'Doesn't draw sort icon in column
        .StrictBestFit = False
        '
        ' Populate RecordControl
        ' for col 0 and 1 set Item.BackColor = ReportControl.PaintManager.CaptionBackColor
        '  
        .Populate
        .FreezeColumnsCount = 2

        ' autosize columns
        For i = .FreezeColumnsCount To .Columns.Count - 1
            .Columns(i).BestFitMode = xtpBestFitModeAllData
            .Columns(i).Resizable = True
            .Columns(i).BestFit
            .Columns(i).Resizable = False
        Next
    End With
End Sub

Private Sub ReportControl_FocusChanging(ByVal NewRow As XtremeReportControl.IReportRow, ... , Cancel As Boolean)
    If Not NewColumn Is Nothing Then
        If NewColumn.Index >= ReportControl.FreezeColumnsCount Then
            ReportControl.SortOrder.DeleteAll
            ReportControl.SortOrder.Add NewColumn
        Else
            Cancel = True
        End If
    End If
End Sub
Private Sub ReportControl_MouseDown(Button As Integer, Shift As Integer, X As Long, Y As Long)
Dim NewColumn As ReportColumn
   
    If ReportControl.HitTest(X, Y).ht = xtpHitTestReportArea Then
        Set NewColumn = ReportControl.HitTest(X, Y).Column
        If NewColumn.Index >= ReportControl.FreezeColumnsCount Then
            ReportControl.SortOrder.DeleteAll
            ReportControl.SortOrder.Add NewColumn
        End If
    End If
   
End Sub
 
I cannot think I can Select a column using a "sort-like" property. But it works.
I need to use checks over FreezeColumnsCount. A new property FixedColumnsCount would be appreciated Wink.
 
Again, thank you all.
 
 
Product: Xtreme SuitePro (ActiveX) version 13.4.1 / 16.3.0

Platform: Windows Vista (32bit) - SP 2

Language: Visual Basic 6.0 (SP6)

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: 06 October 2010 at 8:24am
Hi,
 
If you check my test project, you don't need MouseDown event to get this working. I used that so you can see that it is working. (FocusChange event didn't return NewColumn and NewItem because (I think...) 2 versions were installed and I didn't uninstall previous version) But you can use FocusChange event for this and remove MouseDown event.
 
I also see that you didn't set .Sortable = False for the columns? If you don't set it to false, your users are able to sort by clicking on column.
 
 
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
Albert1 View Drop Down
Groupie
Groupie
Avatar

Joined: 01 February 2007
Location: Italy
Status: Offline
Points: 66
Post Options Post Options   Thanks (0) Thanks(0)   Quote Albert1 Quote  Post ReplyReply Direct Link To This Post Posted: 06 October 2010 at 8:47am
Originally posted by Aaron Aaron wrote:

Hi,
 
If you check my test project, you don't need MouseDown event to get this working. I used that so you can see that it is working.
 
Yes, you are right (to duplicate code is for noobs Embarrassed).
I noticed now you posted it 1 minute before me. I removed the mousedown event and its working anyway.
 
Originally posted by Aaron Aaron wrote:

Hi,
 
I also see that you didn't set .Sortable = False for the columns? If you don't set it to false, your users are able to sort by clicking on column.
Its set  .AllowColumnSort = False at ReportControl level to lock. It works fine.
Product: Xtreme SuitePro (ActiveX) version 13.4.1 / 16.3.0

Platform: Windows Vista (32bit) - SP 2

Language: Visual Basic 6.0 (SP6)

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.160 seconds.