473,395 Members | 1,341 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to store/set the scrollbar's current position?

TheSmileyCoder
2,322 Expert Mod 2GB
I have a form, with a textbox "tb_RibbonXML". It contains alot of text, and as such has a scrollbar. Now when I am editing it, I will usually scrolldown, make a few edits, hit Ctrl-S to save and the record is saved, but the cursor position returns to the start of the textbox.

I have made code to store the cursors position within the textbox:
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3. Private lngCursorPosition
  4. Private lngCursorSelectionLength
  5.  
  6. Private Sub tb_RibbonXml_BeforeUpdate(Cancel As Integer)
  7.       'Record cursor position
  8.       lngCursorPosition = Me.tb_RibbonXml.SelStart
  9.       lngCursorSelectionLength = Me.tb_RibbonXml.SelLength
  10. End Sub
  11.  
And code to reset it after an update:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_AfterUpdate()
  2.    On Error Resume Next
  3.       If Me.ID = lngRibbonID Then
  4.             If Screen.ActiveControl = Me.tb_RibbonXml Then
  5.                'Restore cursor position
  6.                Me.tb_RibbonXml.SelStart = lngCursorPosition
  7.                Me.tb_RibbonXml.SelLength = lngCursorSelectionLength
  8.             End If
  9.       End If
  10. End Sub
This works somewhat, but I would like to refine it more, by being able to store how far the textbox was scrolled down, and restore that information as well.

Anyone have some good suggestions?


This link could be usefull, but I am really not that good with using the declare function to get a function from an API.
Mar 30 '12 #1
0 1554

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Richard van Wegen | last post by:
Dear All I want to use the horizontal scrollbar control, but I can't figure out how to change the width of the slider, i.e. the bit that you drag left & right. With other controls (eg Textbox),...
4
by: BrassWorld | last post by:
Howdy, I know how to tell a DIV with a vertical scroll bar how far to scroll: document.getElementById( 'myDIV' ).scrollTop += 40; However, under certain conditions, 'myDIV' is hidden. Upon...
4
by: Ross | last post by:
I have been using the following script to return a scrollbar to the position it was in before the data was posted. It works in ie but not in firefox. Thanks, R. <script...
4
by: Paul T. RONG | last post by:
Dear all, Can one control the subform scrollbar through vba? For example, I would like to make two command buttons on the main form to control the subform scrollbar. Click 1st button the...
0
by: Tim Bücker | last post by:
Hello. Is it really not possible to hide the scrollbars of a listview ( this.listview.Scrollable = false; ) but do some scrolling anyway ( for instance: PostMessage(this.listview.Handle,...
3
by: Thorbjørn Jørgensen | last post by:
Hi I have some problems understanding the properties for the scrollbar class. F.eks. how do I set the Maximum property in comparison to the Height property if I for example want to have the...
2
by: salpay | last post by:
Hey kids. So I've got a non-updateable recordset in continuous forms, and each row has a button they can click to update the data in that row. So here's the trick I'm using: <do some updates...
7
by: Pachydermitis | last post by:
Hi all you Experts, I need to scroll a listbox horizontally. For the life of me I cannot get it to move. I can successfully scroll it vertically. I have the handle for the listbox and the scroll...
9
by: Jacek Dziedzic | last post by:
Hi! I often find that my programs need to store information on "current mode of something" with two or at most several mutually exclusive "modes" to choose from, e.g. - datafile: is it in a)...
5
Sl1ver
by: Sl1ver | last post by:
I have this piece of code public bool Write(string KeyName, object Value) { try { // Setting string subKey1 =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.