Click here to Skip to main content
15,909,242 members
Home / Discussions / C#
   

C#

 
GeneralBeginner array program, need help!!! Pin
cmh62316-Dec-07 17:17
cmh62316-Dec-07 17:17 
GeneralRe: Beginner array program, need help!!! Pin
CKnig16-Dec-07 18:20
CKnig16-Dec-07 18:20 
GeneralRe: Beginner array program, need help!!! Pin
Yitzchok Dev16-Dec-07 18:26
Yitzchok Dev16-Dec-07 18:26 
GeneralRe: Beginner array program, need help!!! Pin
cmh62316-Dec-07 18:38
cmh62316-Dec-07 18:38 
QuestionHow to make a http Request in Windows Service +Timer Pin
Narendra Mohan16-Dec-07 17:01
Narendra Mohan16-Dec-07 17:01 
AnswerRe: How to make a http Request in Windows Service +Timer Pin
CKnig16-Dec-07 18:23
CKnig16-Dec-07 18:23 
Questiondetecting a word-wrap event in a TextBox or RichTextBox control ? Pin
BillWoodruff16-Dec-07 1:43
professionalBillWoodruff16-Dec-07 1:43 
GeneralRe: detecting a word-wrap event in a TextBox or RichTextBox control ? [modified] Pin
Anthony Mushrow16-Dec-07 6:07
professionalAnthony Mushrow16-Dec-07 6:07 
I can't find anything helpfull either.
All i can suggest is selecting a monotype font, so that you know the width of everyt character, and then work out the height of the text yourself, comparing this to the hieght of the control. And then adjusting as necessary.

So, if every character was 6px wide and 8px high, and the text box was say, 300px wide:

C#
string[] text = richTextBox.Lines;

int height = 0;
foreach(string line in text) {
   int width = line.Length*6;
   height += 300/width; //Conveniently, int will always round up
}

this.richTextBox.Height = height*8; //or height*8 +10; to leave some space, whatever


I think that would work out.

EDIT:Alternitavly, you can inherit from the control, and look into the paint event to see what the drawing does, but that might be a little more complicated.
Alternitavly again, which may be a better solution, would be to inhertin the control, and do the drawing yourself, that way you would know exactly how much space the text takes up. You could make an article of it. Infact, if you don't, i will. (So, that would be 3 articles i must get around to doing Roll eyes | :rolleyes: )

EDIT: fixed a slight mathamatical error
My current favourite word is: Bauble!
-SK Genius


modified on Sunday, December 16, 2007 1:02:24 PM

GeneralRe: detecting a word-wrap event in a TextBox or RichTextBox control ? Pin
BillWoodruff17-Dec-07 4:05
professionalBillWoodruff17-Dec-07 4:05 
GeneralRe: detecting a word-wrap event in a TextBox or RichTextBox control ? Pin
foxjazzdude12-Dec-09 6:00
foxjazzdude12-Dec-09 6:00 
GeneralEnabling dataGridView sorting for a bound List<t></t> Pin
martin_hughes16-Dec-07 1:23
martin_hughes16-Dec-07 1:23 
GeneralRe: Enabling dataGridView sorting for a bound List Pin
martin_hughes16-Dec-07 6:37
martin_hughes16-Dec-07 6:37 
GeneralRe: Enabling dataGridView sorting for a bound List Pin
martin_hughes16-Dec-07 10:34
martin_hughes16-Dec-07 10:34 
GeneralRe: Enabling dataGridView sorting for a bound List Pin
Pete O'Hanlon16-Dec-07 11:27
mvePete O'Hanlon16-Dec-07 11:27 
GeneralRe: Enabling dataGridView sorting for a bound List Pin
martin_hughes16-Dec-07 11:41
martin_hughes16-Dec-07 11:41 
GeneralRe: Enabling dataGridView sorting for a bound List Pin
Pete O'Hanlon16-Dec-07 12:20
mvePete O'Hanlon16-Dec-07 12:20 
GeneralRe: Enabling dataGridView sorting for a bound List Pin
martin_hughes16-Dec-07 12:33
martin_hughes16-Dec-07 12:33 
GeneralRe: Enabling dataGridView sorting for a bound List Pin
Pete O'Hanlon17-Dec-07 1:15
mvePete O'Hanlon17-Dec-07 1:15 
GeneralRe: Enabling dataGridView sorting for a bound List Pin
martin_hughes17-Dec-07 4:45
martin_hughes17-Dec-07 4:45 
GeneralRe: Enabling dataGridView sorting for a bound List Pin
Pete O'Hanlon17-Dec-07 8:56
mvePete O'Hanlon17-Dec-07 8:56 
GeneralRe: Enabling dataGridView sorting for a bound List Pin
martin_hughes17-Dec-07 9:50
martin_hughes17-Dec-07 9:50 
GeneralRe: Enabling dataGridView sorting for a bound List [modified] Pin
Pete O'Hanlon17-Dec-07 10:00
mvePete O'Hanlon17-Dec-07 10:00 
QuestionFilepaths on Linux and Windows Pin
Johan Martensson16-Dec-07 1:04
Johan Martensson16-Dec-07 1:04 
GeneralRe: Filepaths on Linux and Windows Pin
Luc Pattyn16-Dec-07 5:14
sitebuilderLuc Pattyn16-Dec-07 5:14 
GeneralRe: Filepaths on Linux and Windows Pin
Johan Martensson16-Dec-07 22:16
Johan Martensson16-Dec-07 22:16 

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.