Print Page | Close Window

move to last row at form_load

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=12149
Printed Date: 21 November 2024 at 10:33pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: move to last row at form_load
Posted By: winanjaya
Subject: move to last row at form_load
Date 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
 



Replies:
Posted By: Aaron
Date 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....


Posted By: Baldur
Date 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 ?


Posted By: Aaron
Date 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....



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