Hello
When i add new lines of text to my RichTextBox, and when vertical scroll
bar appear (there is more text than RichTextBox can display),
RichTextBox always display "the oldest text" (vertical scrollbar is
always rolled to the top).
And i want to see "fresh text" (vertical scrollbar should be rolled to
bottom position).
How can i do that ?
Thanx 5 13049
check out my thread from yesterday titled...
"going to last line of text in a RichTextBox" Mattin Dechev supplied me an answer that works perfectly.
<us**@domain.in valid> wrote in message news:eP******** ******@TK2MSFTN GP09.phx.gbl... Hello When i add new lines of text to my RichTextBox, and when vertical scroll bar appear (there is more text than RichTextBox can display), RichTextBox always display "the oldest text" (vertical scrollbar is always rolled to the top). And i want to see "fresh text" (vertical scrollbar should be rolled to bottom position). How can i do that ? Thanx
it does not work for me. Program compiles, and run but when text should
be displayed program hangs and thru error:
Additional information: Can not marshal parameter #4: The type
definition of this type has no layout information.
Why ?
This is a test app I just wrote in VS.Net 2003 and it works fine for me..
it has one RichTextBox called richTextBox1 and a time that fires an
AppenText() method to the RichTextBox. here is the code of my form.
using System;
using System.Drawing;
using System.Collecti ons;
using System.Componen tModel;
using System.Windows. Forms;
using System.Data;
using System.Runtime. InteropServices ;
namespace Temp1
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows. Forms.Form
{
private System.Windows. Forms.RichTextB ox richTextBox1;
private System.Windows. Forms.Timer timer1;
private System.Componen tModel.IContain er components;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeCompo nent();
//
// TODO: Add any constructor code after InitializeCompo nent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Disp ose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.components = new System.Componen tModel.Containe r();
this.richTextBo x1 = new System.Windows. Forms.RichTextB ox();
this.timer1 = new System.Windows. Forms.Timer(thi s.components);
this.SuspendLay out();
//
// richTextBox1
//
this.richTextBo x1.Location = new System.Drawing. Point(8, 8);
this.richTextBo x1.Name = "richTextBo x1";
this.richTextBo x1.Size = new System.Drawing. Size(248, 168);
this.richTextBo x1.TabIndex = 0;
this.richTextBo x1.Text = "richTextBo x1";
this.richTextBo x1.TextChanged += new
System.EventHan dler(this.richT extBox1_TextCha nged);
//
// timer1
//
this.timer1.Ena bled = true;
this.timer1.Tic k += new System.EventHan dler(this.timer 1_Tick);
//
// Form1
//
this.AutoScaleB aseSize = new System.Drawing. Size(5, 13);
this.ClientSize = new System.Drawing. Size(264, 190);
this.Controls.A dd(this.richTex tBox1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayo ut(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run (new Form1());
}
private void timer1_Tick(obj ect sender, System.EventArg s e) {
richTextBox1.Ap pendText("Added Line of Text");
}
#region external declarations for making output box always show last line.
const int SB_VERT = 1;
const int EM_SETSCROLLPOS = 0x0400 + 222;
[DllImport("user 32", CharSet=CharSet .Auto)]
static extern bool GetScrollRange( IntPtr hWnd, int nBar, out int lpMinPos,
out int lpMaxPos);
[DllImport("user 32", CharSet=CharSet .Auto)]
static extern IntPtr SendMessage(Int Ptr hWnd, int msg, int wParam, POINT
lParam);
[StructLayout(La youtKind.Sequen tial)]
class POINT {
public int x;
public int y;
public POINT() { }
public POINT(int x, int y) {
this.x = x;
this.y = y;
}
}
#endregion
private void richTextBox1_Te xtChanged(objec t sender, System.EventArg s e) {
int min, max;
GetScrollRange( richTextBox1.Ha ndle, SB_VERT, out min, out max);
SendMessage(ric hTextBox1.Handl e, EM_SETSCROLLPOS , 0, new POINT(0, max -
richTextBox1.He ight));
}
}
}
Thanx a lot.
i did not inlude [StructLayout(La youtKind.Sequen tial)]....
Now it works fine :)
by the way:
There is TextChanged event in TextBox class, what is appriopriate event
in ListView class ? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: nouno |
last post by:
I am trying to spell check a richtextbox. Through code (shown below) I
save the contents of the richtextbox to a rtf file, open the rtf file
in Word, spell check it, save it, and then load the ftf file back into
the ricktextbox using loadfile.
The problem is that the richtextbox seems to remain bound to the rtf
file. If I make a change in the richtextbox after spell checking, the
changes are successfully saved to the database but if the...
|
by: Blazej Czeladzki \(ByCZy\) |
last post by:
Is it possible to syncronize scrollbars in two separate richTextBox-es????
--
_____________
Pozdrawiam:
Blazej Czeladzki
|
by: Dino M. Buljubasic |
last post by:
I have a treeview and a checked list view controls one beside another. I
want to make them work so that when I scroll down or up one of them the
other does the same.
Any help will be appreciated
--
Dino Buljubasic
Software Developer
http://rivusglobal.com
|
by: JonnyT |
last post by:
I searched high and low for an answer on how to auto scroll a
richtextbox and now I finally have it. Since it took me a while to
get a good efficient way of doing it that didn't require focus to the
control or the scrolltocaret method I decided that it would be worth
posting to anyone who might have similar concerns. For the record
this works well in an environment where you cannot have focus going to
the richtextbox....such as a chat...
|
by: vb.net controls |
last post by:
Hi evryone...
i'm a beginner in vb.net. I have a form with two RichTextBox and when
i move the Scrollbar of one i would like that the second move at the
same time.
I really have no idea of how to do it.
Thanks for your help
| |
by: Vincent |
last post by:
Dear all,
I have implemented a class to export the content of RichTextBox to
image in WYSISYG mode so that line breaks on the screen are the same as
exported.
C# Code:
public struct STRUCT_RECT
|
by: James Wong |
last post by:
Hi,
I use the RichTextBox in my program.
It will use different language in this RichTextBox (chinese and english
characters), and it set the "DualFont" and use different fonts.
By the way, how can I print out this content to printer easily?
Thanks!
James
|
by: michael sorens |
last post by:
The documentation for the RichTextBox is sketchy at best. I want to do a
very simple task but I cannot find information on this. I am using a
RichTextBox as an output window. Some text I want to just add plain (e.g..
rtf.Text += "new stuff..."; ) but some text, when added, I want to be in a
different color or font size. Find() will not work because the text will
vary. I have delimiters on it so I could recognize it with a regular ...
|
by: Vimalathithan |
last post by:
I just developing a editor. I have provide the options like Bold, Italic, underlin, font change, font size change. These font options are keep in with one toolstripbutton. the toolstripbar keep inside with panel.
The RichTextBox keep inside with other panel. The panel height and width is same with RichTextBox. The RichTextBox both scrolling options are make it as false.
I done the coding for RichTextBox's height to fit with...
|
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: 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: 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: 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: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |