Click here to Skip to main content
15,887,596 members
Home / Discussions / C#
   

C#

 
GeneralChange User Windows Rights Pin
marsiglia22-Sep-03 22:54
marsiglia22-Sep-03 22:54 
GeneralRe: Change User Windows Rights Pin
shaunAustin22-Sep-03 23:22
shaunAustin22-Sep-03 23:22 
GeneralQuick boolean question: DataGrids.DataSource: multi datatables Pin
troels_sorensen22-Sep-03 22:44
troels_sorensen22-Sep-03 22:44 
Generalencode a path to binary and store to database Pin
M_|222-Sep-03 22:03
M_|222-Sep-03 22:03 
GeneralRe: encode a path to binary and store to database Pin
shaunAustin22-Sep-03 23:28
shaunAustin22-Sep-03 23:28 
GeneralDLL CAll Pin
anees8122-Sep-03 20:56
anees8122-Sep-03 20:56 
Questionhow to use c# to sned message to a mobile phone Pin
Jim Chan22-Sep-03 20:20
Jim Chan22-Sep-03 20:20 
GeneralIntegral Number of Lines in RichTextBox Pin
Andrew Shapira22-Sep-03 18:08
Andrew Shapira22-Sep-03 18:08 
Hello,

How can one set up a RichTextBox so that the box shows an integral number of text lines, say 17, when the text box is scrolled all the way down? Possibly this would involve making the RichTextBox have a particular size.

The example below shows what I tried: set ClientSize.Height to be a multiple of Font.Height. It didn't work. When the text box is scrolled all the way down, a piece of a line shows at the top, which looks bad. I don't know how to calculate the amount by which the sizing is off.

(This rich text box will always be scrolled all the way down. Thanks to posters who responded to "help me, how to autoscroll in richtextbox" by KETUINHA for showing me how to do this.)

By the way, how can one post code in these forums and have the code's indentation be preserevd? Using 'code' tags ended up with no indentation, at least according to the preview.


using System;
using System.Drawing;
using System.Text;
using System.Windows.Forms;


class TextBoxTesterForm : Form
{
public TextBoxTesterForm()
{
int lines = 5;

d_rtb = new RichTextBox();
d_rtb.SuspendLayout();
d_rtb.Parent = this;
d_rtb.Location = new Point(10,10);
int desiredTextHeight = lines * d_rtb.Font.Height;
d_rtb.ClientSize = new Size(200, desiredTextHeight);
d_rtb.ResumeLayout();

Console.WriteLine("lines={0}", lines);
Console.WriteLine("rtb Font.Height = {0}",
d_rtb.Font.Height);
Console.WriteLine("rtb Font.GetHeight() = {0}",
d_rtb.Font.GetHeight());
Console.WriteLine("desiredTextHeight = {0}",
desiredTextHeight);
Console.WriteLine("rtb ClientSize = {0}",
d_rtb.ClientSize);
Console.WriteLine("rtb DisplayRectangle = {0}",
d_rtb.DisplayRectangle);
Console.WriteLine("rtb Size = {0}", d_rtb.Size);
Console.WriteLine("rtb Multiline = {0}", d_rtb.Multiline);
}

RichTextBox d_rtb;
}

class TextBoxTestMain {
static void Main()
{ Application.Run(new TextBoxTesterForm()); }
}

GeneralRe: Integral Number of Lines in RichTextBox Pin
Blake Coverett22-Sep-03 22:14
Blake Coverett22-Sep-03 22:14 
GeneralRe: Integral Number of Lines in RichTextBox Pin
Andrew Shapira22-Sep-03 22:26
Andrew Shapira22-Sep-03 22:26 
GeneralRe: Integral Number of Lines in RichTextBox Pin
Blake Coverett22-Sep-03 23:09
Blake Coverett22-Sep-03 23:09 
GeneralRe: Integral Number of Lines in RichTextBox Pin
Blake Coverett22-Sep-03 23:20
Blake Coverett22-Sep-03 23:20 
GeneralRe: Integral Number of Lines in RichTextBox Pin
Andrew Shapira23-Sep-03 0:06
Andrew Shapira23-Sep-03 0:06 
GeneralRe: Integral Number of Lines in RichTextBox Pin
Blake Coverett23-Sep-03 5:58
Blake Coverett23-Sep-03 5:58 
GeneralRe: Integral Number of Lines in RichTextBox Pin
Andrew Shapira23-Sep-03 9:12
Andrew Shapira23-Sep-03 9:12 
GeneralRe: Integral Number of Lines in RichTextBox Pin
Andrew Shapira23-Sep-03 0:01
Andrew Shapira23-Sep-03 0:01 
Generalnewbie trying to Pinvoke Pin
jpervaz22-Sep-03 17:33
jpervaz22-Sep-03 17:33 
GeneralRe: newbie trying to Pinvoke Pin
Blake Coverett22-Sep-03 17:51
Blake Coverett22-Sep-03 17:51 
GeneralRe: newbie trying to Pinvoke Pin
jpervaz23-Sep-03 3:40
jpervaz23-Sep-03 3:40 
GeneralRe: newbie trying to Pinvoke Pin
Blake Coverett23-Sep-03 6:10
Blake Coverett23-Sep-03 6:10 
Generalbuilding a canned email sender Pin
frank2122-Sep-03 14:05
frank2122-Sep-03 14:05 
GeneralRe: building a canned email sender Pin
fadee22-Sep-03 20:43
fadee22-Sep-03 20:43 
GeneralObjectStreams in .NET Pin
Anonymous22-Sep-03 13:18
Anonymous22-Sep-03 13:18 
GeneralRe: ObjectStreams in .NET Pin
J. Dunlap22-Sep-03 15:38
J. Dunlap22-Sep-03 15:38 
GeneralRe: From MFC to C# Serialization Pin
J. Dunlap22-Sep-03 10:54
J. Dunlap22-Sep-03 10:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.