Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Report Control
  New Posts New Posts RSS Feed - move to last row at form_load
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

move to last row at form_load

 Post Reply Post Reply
Author
Message
winanjaya View Drop Down
Groupie
Groupie


Joined: 07 August 2005
Location: Indonesia
Status: Offline
Points: 19
Post Options Post Options   Thanks (0) Thanks(0)   Quote winanjaya Quote  Post ReplyReply Direct Link To This Post Topic: move to last row at form_load
    Posted: 14 September 2008 at 11:17am
Dear All,
 
I am trying to move to last row at form load .. but it doesnot work.. what I missed? I need advise
 
Thanks & Regards
Winanjaya
 
Private Sub Form_Load()
CreateReportControl
End Sub

Private Sub CreateReportControl()
    'Start adding columns
    Dim Column As ReportColumn
    Set Column = wndReportControl.Columns.Add(COLUMN_SENT1, "Sent Date", 50, True)
    Set Column = wndReportControl.Columns.Add(COLUMN_SENT2, "Sent Time", 50, True)
    Set Column = wndReportControl.Columns.Add(COLUMN_FROM, "From", 180, True)
    Set Column = wndReportControl.Columns.Add(COLUMN_TO, "To", 180, True)
    Set Column = wndReportControl.Columns.Add(COLUMN_MSG, "Msg", 180, False)
    wndReportControl.PaintManager.MaxPreviewLines = 1
             
    PopulateSentItems
   
    wndReportControl.GroupsOrder.Add wndReportControl.Columns(0)
    wndReportControl.GroupsOrder(0).SortAscending = True
    wndReportControl.Columns(4).Visible = False
   
    Set fntStrike = wndReportControl.PaintManager.TextFont
    fntStrike.Strikethrough = True
   
    Set fntBold = wndReportControl.PaintManager.TextFont
    fntBold.Bold = True
   
    wndReportControl.Populate
    wndReportControl.SetCustomDraw xtpCustomBeforeDrawRow
    wndReportControl.Rows.Row(wndReportControl.Rows.Count - 1).Selected = True
End Sub
 
Private Sub PopulateSentItems()
Dim rsSentItems As New ADODB.Recordset
Dim mSQL As String
Dim mFrom As String, mTo As String, mUDate As String, mUTime As String, mMsg As String
mSQL = "SELECT * FROM SMS WHERE STAT = '" & STAT & "' ORDER BY UDATE,UTIME"
rsSentItems.Open mSQL, cnData, adOpenForwardOnly, adLockReadOnly
If Not rsSentItems.EOF Then
    Do
        mFrom = rsSentItems!SENDER
        mTo = rsSentItems!dest
        mUDate = Format(rsSentItems!UDATE, "dd-mmm-yyyy")
        mUTime = Format(rsSentItems!UTIME, "hh:nn")
        mMsg = rsSentItems!MSG
        AddRecord mFrom, mTo, mUDate, mUTime, mMsg
        rsSentItems.MoveNext
    Loop Until rsSentItems.EOF
End If
errhand:
rsSentItems.Close
End Sub
 
Public Sub AddRecord(ByVal pFrom As String, ByVal pTo As String, ByVal pUDate, ByVal pUTime As String, ByVal pPreview As String)
Dim Record As ReportRecord
Set Record = wndReportControl.Records.Add()
Dim Item As ReportRecordItem
Set Item = Record.AddItem("")
Record.AddItem pUDate
Record.AddItem pUTime
Record.AddItem pFrom
Record.AddItem pTo
Record.AddItem pPreview
Record.PreviewText = pPreview
End Sub
 
Private Sub wndReportControl_SelectionChanged()
    If Not wndReportControl.FocusedRow.GroupRow Then
        rtfText.Text = wndReportControl.FocusedRow.Record.PreviewText
    End If
End Sub
 
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: 16 September 2008 at 1:01pm
Hi,
 
You can use:
  1. wndReportControl.Navigator.MoveToRow wndReportControl.Rows.Count, False, False
  2. wndReportControl.Navigator.MoveLastRow False, False
  3. wndReportControlFiles.Rows(wndReportControlFiles.Rows.Count - 1).Selected = True
But it seems that selecting the last row doesn't work as should. It selects the row but doesn't scroll to the last row. I have commandbars in form and when I float the CB the last row will be visible.
 
Try to set one of these methods at the end of form load and you will see that it works, also have the form maximized will work as should. I will add this "problem" to my major issue post and CJ will have a fix in next release.
 
 
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
Baldur View Drop Down
Senior Member
Senior Member


Joined: 22 November 2006
Location: Germany
Status: Offline
Points: 244
Post Options Post Options   Thanks (0) Thanks(0)   Quote Baldur Quote  Post ReplyReply Direct Link To This Post Posted: 17 September 2008 at 3:04am
You can use:
 
Set MyReport.FocusedRow = MyReport.Rows(MyIndex)
 
This works as EnsureVisible in other controls.
 
Because you can have multiple selected rows, which should by focused ?
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: 17 September 2008 at 2:04pm
Hi,
 
I found: when having a VB menu the RC selects last row but doesn't scroll to last row. I added DoEvents after populating RC and now the RC scrolls to last row as should.
 
 
wndReportControl.Populate
DoEvents
 
 
You can use one of the following lines:
  1. wndReportControl.Navigator.MoveToRow wndReportControl.Rows.Count - 1, False, False
  2. wndReportControl.Navigator.MoveLastRow False, False
  3. wndReportControl.Rows(wndReportControl.Rows.Count - 1).Selected = True
  4. wndReportControl.FocusedRow = wndReportControl.Rows(wndReportControl.Rows.Count - 1)
No 2 is best way, this is by design
 
 
 
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.188 seconds.