Hello,
How do you scroll to the bottom of a multiline textbox in code?
Mel 7 69354
Set the start of the seleciton to be the length of the text.
--
John Wood
EMail: first name, dot, second name at priorganize.com
"Mel Weaver" <Mel@[remove spam]insdirect.com> wrote in message
news:%2******** **********@tk2m sftngp13.phx.gb l... Hello, How do you scroll to the bottom of a multiline textbox in code?
Mel
Try this
this.textBox1.S electionStart = textBox1.Text.L ength;
this.textBox1.S crollToCaret();
Shak.
"Mel Weaver" <Mel@[remove spam]insdirect.com> wrote in message
news:#4******** ******@tk2msftn gp13.phx.gbl... Hello, How do you scroll to the bottom of a multiline textbox in code?
Mel
Mel,
You can use the previously posted responses if you don't mind the caret
position being moved. If you do not want to change the caret position, then
you will have to send the WM_VSCROLL message to the textbox, like so:
private const int WM_VSCROLL = 0x115;
private const int SB_BOTTOM = 7;
[DllImport("user 32.dll", CharSet=CharSet .Auto)]
private static extern int SendMessage(Int Ptr hWnd, int wMsg, IntPtr wParam,
IntPtr lParam);
// Scroll to the bottom, but don't move the caret position.
SendMessage(tex tBox1.Handle, WM_VSCROLL, (IntPtr) SB_BOTTOM, IntPtr.Zero);
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Mel Weaver" <Mel@[remove spam]insdirect.com> wrote in message
news:%2******** **********@tk2m sftngp13.phx.gb l... Hello, How do you scroll to the bottom of a multiline textbox in code?
Mel
Nicholas,
do you know how to disable the context menu of displayed vertical and
horizontal scroll bar in the textbox?. How to insert my own menu there
overiding scrollbar menu?
Shak.
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:uX******** *****@TK2MSFTNG P11.phx.gbl... Mel,
You can use the previously posted responses if you don't mind the
caret position being moved. If you do not want to change the caret position,
then you will have to send the WM_VSCROLL message to the textbox, like so:
private const int WM_VSCROLL = 0x115; private const int SB_BOTTOM = 7;
[DllImport("user 32.dll", CharSet=CharSet .Auto)] private static extern int SendMessage(Int Ptr hWnd, int wMsg, IntPtr
wParam, IntPtr lParam);
// Scroll to the bottom, but don't move the caret position. SendMessage(tex tBox1.Handle, WM_VSCROLL, (IntPtr) SB_BOTTOM, IntPtr.Zero);
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard. caspershouse.co m
"Mel Weaver" <Mel@[remove spam]insdirect.com> wrote in message news:%2******** **********@tk2m sftngp13.phx.gb l... Hello, How do you scroll to the bottom of a multiline textbox in code?
Mel
Shakir,
I think that it can be done, but it would take a LOT of work. I was
able to get the menu to not come up, but unfortunately, it messed with how
the cursor was displayed, as well as the scrolling.
What it involves is intercepting the WM_NCHITTEST message. This is sent
to the control to query what elements are where. If the result indicated
that the hittest was for the vertical scrollbar, then I changed it to
indicate that it was part of the client. This caused the context menu to
pop up, but not much else.
I imagine it is possible by installing hooks for the current thread. It
would involve determining when the WM_NCHITTEST message is sent. Once you
do that, you would have to have the mouse event hook cancel out the sending
of the event to the textbox, if it was determined that the menu was going to
be shown.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Shakir Hussain" <sh**@fakedomai n.com> wrote in message
news:us******** ******@TK2MSFTN GP10.phx.gbl... Nicholas,
do you know how to disable the context menu of displayed vertical and horizontal scroll bar in the textbox?. How to insert my own menu there overiding scrollbar menu?
Shak.
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote
in message news:uX******** *****@TK2MSFTNG P11.phx.gbl... Mel,
You can use the previously posted responses if you don't mind the caret position being moved. If you do not want to change the caret position, then you will have to send the WM_VSCROLL message to the textbox, like so:
private const int WM_VSCROLL = 0x115; private const int SB_BOTTOM = 7;
[DllImport("user 32.dll", CharSet=CharSet .Auto)] private static extern int SendMessage(Int Ptr hWnd, int wMsg, IntPtr wParam, IntPtr lParam);
// Scroll to the bottom, but don't move the caret position. SendMessage(tex tBox1.Handle, WM_VSCROLL, (IntPtr) SB_BOTTOM,
IntPtr.Zero); Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard. caspershouse.co m
"Mel Weaver" <Mel@[remove spam]insdirect.com> wrote in message news:%2******** **********@tk2m sftngp13.phx.gb l... Hello, How do you scroll to the bottom of a multiline textbox in code?
Mel
Thanks man,
Shak.
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:eb******** ******@TK2MSFTN GP09.phx.gbl... Shakir,
I think that it can be done, but it would take a LOT of work. I was able to get the menu to not come up, but unfortunately, it messed with how the cursor was displayed, as well as the scrolling.
What it involves is intercepting the WM_NCHITTEST message. This is
sent to the control to query what elements are where. If the result indicated that the hittest was for the vertical scrollbar, then I changed it to indicate that it was part of the client. This caused the context menu to pop up, but not much else.
I imagine it is possible by installing hooks for the current thread.
It would involve determining when the WM_NCHITTEST message is sent. Once you do that, you would have to have the mouse event hook cancel out the
sending of the event to the textbox, if it was determined that the menu was going
to be shown.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard. caspershouse.co m
"Shakir Hussain" <sh**@fakedomai n.com> wrote in message news:us******** ******@TK2MSFTN GP10.phx.gbl... Nicholas,
do you know how to disable the context menu of displayed vertical and horizontal scroll bar in the textbox?. How to insert my own menu there overiding scrollbar menu?
Shak.
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in message news:uX******** *****@TK2MSFTNG P11.phx.gbl... Mel,
You can use the previously posted responses if you don't mind the caret position being moved. If you do not want to change the caret
position, then you will have to send the WM_VSCROLL message to the textbox, like so:
private const int WM_VSCROLL = 0x115; private const int SB_BOTTOM = 7;
[DllImport("user 32.dll", CharSet=CharSet .Auto)] private static extern int SendMessage(Int Ptr hWnd, int wMsg, IntPtr wParam, IntPtr lParam);
// Scroll to the bottom, but don't move the caret position. SendMessage(tex tBox1.Handle, WM_VSCROLL, (IntPtr) SB_BOTTOM, IntPtr.Zero); Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard. caspershouse.co m
"Mel Weaver" <Mel@[remove spam]insdirect.com> wrote in message news:%2******** **********@tk2m sftngp13.phx.gb l... > Hello, > How do you scroll to the bottom of a multiline textbox in code? > > Mel > >
Nicholas,
Quickly noticed that the scrollbar of the preview window of outlook express
shows the custom context menu.
Shak.
"Shakir Hussain" <sh**@fakedomai n.com> wrote in message
news:us******** ******@TK2MSFTN GP10.phx.gbl... Nicholas,
do you know how to disable the context menu of displayed vertical and horizontal scroll bar in the textbox?. How to insert my own menu there overiding scrollbar menu?
Shak.
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote
in message news:uX******** *****@TK2MSFTNG P11.phx.gbl... Mel,
You can use the previously posted responses if you don't mind the caret position being moved. If you do not want to change the caret position, then you will have to send the WM_VSCROLL message to the textbox, like so:
private const int WM_VSCROLL = 0x115; private const int SB_BOTTOM = 7;
[DllImport("user 32.dll", CharSet=CharSet .Auto)] private static extern int SendMessage(Int Ptr hWnd, int wMsg, IntPtr wParam, IntPtr lParam);
// Scroll to the bottom, but don't move the caret position. SendMessage(tex tBox1.Handle, WM_VSCROLL, (IntPtr) SB_BOTTOM,
IntPtr.Zero); Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard. caspershouse.co m
"Mel Weaver" <Mel@[remove spam]insdirect.com> wrote in message news:%2******** **********@tk2m sftngp13.phx.gb l... Hello, How do you scroll to the bottom of a multiline textbox in code?
Mel
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mad Scientist Jr |
last post by:
I have a textbox that i am adding to (in codebehind of ASP.NET) and
need to ensure that the focus is scrolled to the bottom of the textbox
each time the page refreshes, and then set focus to a 2nd textbox
(which the user types input into).
I have tried a couple functions I found posted online but they don't
work (see below)
The closest I got was using the scrolldown method:
|
by: Alex Moskalyuk |
last post by:
I am using System.Windows.Forms.TextBox to publish some real-time data
that's coming off the external devices. My data is fed into the TextBox with
proper precautions not to exceed the MaxSize limit. I use the AppendText()
method of the TextBox class and tried playing with ScrollToCaret(), but that
didn't seem to do anything different than normal behavior.
I am getting the TextBox that supports auto-scrolling on some machines (i.e.
the...
|
by: JC |
last post by:
I'm sure you've all seen the save scroll position from 4 guys from
rolla which can be found here >
http://aspnet.4guysfromrolla.com/articles/111704-1.aspx
BUT
try to get that to work AND still be able to set the focus to a
control.
Here's the problem, when you set the focus by using the
registerstartupscript method the control gets the focus after the
scroll position has been set. When this happens the scroll position
|
by: Rob T |
last post by:
I have a multiline textbox that shows a log. When I keep adding items to
the textbox, I would like it to autoscroll to the bottom. I thought moving
the cursor to the end would do it like (ie.
boxHistory.SelectionStart=999999), which does move the cursor, but doesn't
scroll.
How would I do this? Thanks.
-Rob T.
|
by: Rvo |
last post by:
I have a userform which contains a textbox (System.Windows.forms.textbox)
with multiline set to True. This box contains a certain number of characters
which reach below the bottom of the box. During runtime of my program I add
text at the end of the contents of the textbox. I want to display the last
lines of the box at all times.
However, the textbox always displays the first x characters.
Can I scroll down to the end of the content of...
| |
by: UJ |
last post by:
I've got a multiline textbox that I'm using to display messages. Is there an
easy way to have it scroll to the end after I add a line to the text of the
box?
TIA - Jeff.
|
by: Rachel |
last post by:
I am developing an application for Windows Mobile devices using C#. I have a
form that has several controls (labels and textboxes that are dynamically
created on opening the form) and a vertical scroll bar. The number of
controls varies. Everything works well and the scroll bar resizes acc to the
number of controls.
Only problem I am having is that when the user is entering data and the
control is at the bottom of the form the scroll bar...
|
by: Brian Keating |
last post by:
Hi there,
Does anyone know if i can determin if the scroll position is at the bottom
of my textbox?
I can get the scroll position fine, but how do i know if it's actually at
the bottom?
thanks in advance
Brian.
|
by: NehaDas |
last post by:
Hello Everyone !
Iam relatively new to .NET C# and m still in the process of exploring various options. Any help with regard to this query will be highly appreciated ...
Iam working on an application that somewhat is similar to outlook .
It will have a list of messages received on top and a reading pane below displaying the message selected by user.
The problem is as follows :
The screen is structured in the form of 3 taskcards :
1)New...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |