Lost Password?


  #1 (permalink)  
Old 05-09-2006, 08:31 AM
Lop's Avatar   
Lop Lop is offline
Speaks fluent binary
 
Join Date: May 2006
Posts: 1,149
Rep Power: 18
Lop will become famous soon enoughLop will become famous soon enough
Default Number of Lines on a RichText Box

How can I find the number of lines on a richtextbox? I'd like to know how many lines I could paste.
__________________
Lop
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 05-10-2006, 05:14 AM
RobSoftware RobSoftware is offline
Programmer
 
Join Date: Nov 2005
Posts: 143
Rep Power: 12
RobSoftware is on a distinguished road
Default

Code:
		 ////////////////////////////////////////////////////////////
		 //** This returns the total number of lines the rich
		 //** text box can hold
		 ////////////////////////////////////////////////////////////
private: int GetTotalNumberLines() {
			 String^ text = "TEST STRING";
			 System::Drawing::Font^ textFont = richTextBox1->Font;
			 
			 //Specify a fixed width, but let the height be "unlimited"
			 SizeF^ layoutSize = gcnew SizeF((float)richTextBox1->Width, 
				 (float)5000.0F);
			 Graphics^ g = Graphics::FromHwnd(richTextBox1->Handle);
			 SizeF^ stringSize = g->MeasureString(text, textFont, (SizeF)layoutSize);

			 // Divide RTB height by font height to determine how many it can hold.
			 int numLines = richTextBox1->Height / stringSize->Height;

			 // Return the number
			 return numLines;
		 }
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 06-15-2006, 07:26 PM
Lop's Avatar   
Lop Lop is offline
Speaks fluent binary
 
Join Date: May 2006
Posts: 1,149
Rep Power: 18
Lop will become famous soon enoughLop will become famous soon enough
Default

Works perfect! Thank you!
__________________
Lop
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 06-16-2006, 06:19 PM
dirkfirst dirkfirst is offline
Programming Professional
 
Join Date: May 2006
Posts: 338
Rep Power: 12
dirkfirst is on a distinguished road
Default

Nice code! how long have you been using .NET Rob?
__________________
DirkFirst
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Floating Point random number generator Paradine PHP Tutorials 0 08-26-2007 03:09 PM
Number Cloning Ronin Java Help 3 12-21-2006 08:23 AM
Removing lines from a file NeedHelp C and C++ 1 11-01-2006 01:10 PM
I need to generate a random number in PHP dirkfirst PHP Forum 7 07-05-2006 10:58 PM
Number of files and directories in folder dirkfirst PHP Forum 4 05-30-2006 11:06 AM


All times are GMT -5. The time now is 05:25 PM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 100%


Complete - Celebrate!

Ads