Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Report Control
  New Posts New Posts RSS Feed - DateTimePicker in RC Item
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

DateTimePicker in RC Item

 Post Reply Post Reply
Author
Message
kerog View Drop Down
Newbie
Newbie


Joined: 21 March 2012
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote kerog Quote  Post ReplyReply Direct Link To This Post Topic: DateTimePicker in RC Item
    Posted: 24 September 2012 at 5:24am

How to add custom control to ReportRecordItem? I'd like to add to Item DateTimePicker.

Can you give an example ho to do it?

Regards

Product: Xtreeme SuitePro (activeX) v. 15.3.1
Platform: MS Vista Buisness (32bit) SP2 PL
IDE: PowerBuilder 11.5.1
Back to Top
Xander75 View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 April 2007
Status: Offline
Points: 353
Post Options Post Options   Thanks (0) Thanks(0)   Quote Xander75 Quote  Post ReplyReply Direct Link To This Post Posted: 06 November 2012 at 5:20am
Hi,

The following code example shows how to add the DateTimePicker control, but can be used for any control. The original version of this code is found at: http://forum.codejock.com/forum_posts.asp?TID=18679&KW=DateTimePicker&title=adding-control-please-help

However I have changed the code to use the BeginEdit event as this works better than FocusChanging. I also tweaked the code to set the position relative to the ReportControls position, as this is not always set as Left = 0 and Top = 0 on the screen.

The code for showing/hiding the DateTimePicker has been added to a module so this can be reusable for any ReportControl.

Note: I prefer to use the MSComCtl2.DTPicker instead of Codejocks XtremeSuiteControls.DateTimePicker as it allows me to change the colours. I find the XtremeSuiteControls.DateTimePicker Day names to be unreadable when used in conjunction with the SkinFramework control. Plus if you use the XtremeSuiteControls.DateTimePicker you will find the navigation on press of the Tab key doesn't quite work correctly as when the DateTimePicker has focus it then moves out of the ReportControl into other controls even with TabStop set as false! Using the MSComCtl2.DTPicker resolves this when setting TabStop to False allowing the Tab key navigation to flow correctly within the ReportControl even when the DTPicker has focus.

Form Code
' Some test data for this example
Private Sub Form_Load()
    With ReportControl
        .AllowEdit = True
        .AutoColumnSizing = True
        .EditOnClick = True
        .FocusSubItems = True
       
        Dim Column As ReportColumn
        Set Column = .Columns.Add(0, "Column 1", 150, False)
        Set Column = .Columns.Add(1, "Date 1", 90, False)
        Set Column = .Columns.Add(2, "Date 2", 90, False)
       
        .Populate
       
        Dim Record As ReportRecord
        For i = 0 To 100
            Set Record = .Records.Add
            With Record
                .AddItem "Row: " & i
                .AddItem Date
                .AddItem Date
            End With
        Next
       
        .Populate
    End With
End Sub

' Below is the code events required for the DateTimePicker & ReportControl
Private Sub DateTimePicker_Change()
    ReportControl.FocusedRow.Record(ReportControl.FocusedColumn.Index).Value = DateTimePicker.Value
    ReportControl.Populate
End Sub

Private Sub ReportControl_BeginEdit(ByVal Row As XtremeReportControl.IReportRow, ByVal Column As XtremeReportControl.IReportColumn, ByVal Item As XtremeReportControl.IReportRecordItem)
    DateTimePicker.Visible = False
    Select Case Column.Index
        Case 1, 2
            Call ShowDatePicker(ReportControl, DateTimePicker, Row, Column, Item)
    End Select
End Sub

Private Sub ReportControl_FocusChanging(ByVal NewRow As XtremeReportControl.IReportRow, ByVal NewColumn As XtremeReportControl.IReportColumn, ByVal NewItem As XtremeReportControl.IReportRecordItem, Cancel As Boolean)
    Call HideDatePicker(DateTimePicker)
End Sub

Private Sub ReportControl_VScroll(ByVal Section As Long, ByVal Position As Long)
    Call HideDatePicker(DateTimePicker)
End Sub

Module Code
Public Sub HideDatePicker(ByVal DTPicker As XtremeSuiteControls.DateTimePicker)
    With DTPicker
        .Move -10000, -10000, DTPicker.Width, DTPicker.Height
        .ZOrder 1
        .Visible = False
    End With
End Sub

Public Sub ShowDatePicker(ByVal rc As XtremeReportControl.ReportControl, ByVal DTPicker As XtremeSuiteControls.DateTimePicker, ByVal Row As XtremeReportControl.IReportRow, ByVal Column As XtremeReportControl.IReportColumn, ByVal Item As XtremeReportControl.IReportRecordItem)
    Dim l As Long, t As Long, r As Long, b As Long, x As Long, y As Long
    x = Screen.TwipsPerPixelX
    y = Screen.TwipsPerPixelY
   
    rc.Rows(Row.Index).GetItemRect Item, l, t, r, b
    l = l * x
    t = t * y
    r = r * x
    b = b * y

    With DTPicker
        .Move (rc.Left + x) + l, (rc.Top + y) + t, (r - l) + x, (b - t) + y
        .ZOrder 0
        .Visible = True
        .Value = Item.Value
    End With
End Sub

Product: Xtreme SuitePro (ActiveX) v15.3.1
Platform: Windows 7 64-bit (SP1) Professional Edition
Languages: C#.Net using Visual Studio 2012 & 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.142 seconds.