Click here to Skip to main content
15,922,325 members
Home / Discussions / C#
   

C#

 
GeneralRe: Single instance forms in an MDI app [modified] Pin
martin_hughes8-Sep-07 13:38
martin_hughes8-Sep-07 13:38 
GeneralRe: Single instance forms in an MDI app Pin
Ed.Poore8-Sep-07 13:51
Ed.Poore8-Sep-07 13:51 
GeneralRe: Single instance forms in an MDI app Pin
martin_hughes8-Sep-07 14:18
martin_hughes8-Sep-07 14:18 
GeneralRe: Single instance forms in an MDI app Pin
Ed.Poore9-Sep-07 0:19
Ed.Poore9-Sep-07 0:19 
GeneralRe: Single instance forms in an MDI app Pin
martin_hughes9-Sep-07 7:36
martin_hughes9-Sep-07 7:36 
GeneralRe: Single instance forms in an MDI app Pin
Ed.Poore9-Sep-07 9:12
Ed.Poore9-Sep-07 9:12 
GeneralRe: Single instance forms in an MDI app Pin
Ed.Poore9-Sep-07 13:39
Ed.Poore9-Sep-07 13:39 
QuestionNeed an Algorithm like 'Word Wrap' in notepad. Pin
hdv2128-Sep-07 6:54
hdv2128-Sep-07 6:54 
hi i need an algorithm like 'Word Wrap' in notepad that place my words in some lines that fit in my border(like richtextBox), i wrote this code, but it's not work correctly :
private void ShowText()<br />
        {            <br />
            string mainText = System.IO.File.ReadAllText("test.txt");<br />
            Graphics g = this.richTextBox1.CreateGraphics();<br />
            int widthBorder = this.richTextBox1.Width;<br />
            StringBuilder sb = new StringBuilder();<br />
            SizeF sizeText = new SizeF();<br />
            SizeF sizeCurrentLine = new SizeF();<br />
            ArrayList allLines = new ArrayList();<br />
            string firstWordNextLine = string.Empty;<br />
<br />
            string[] textCol = mainText.Split(new char[] { ' ' });<br />
            foreach (string text in textCol)<br />
            {             <br />
                if (firstWordNextLine != string.Empty)<br />
                {<br />
                    sb.Append(firstWordNextLine);<br />
                    firstWordNextLine = string.Empty;<br />
                }<br />
                int widthText = (int)g.MeasureString(text, this.richTextBox1.Font).Width;<br />
                int widthCurrentLine = (int)g.MeasureString(sb.ToString(), this.richTextBox1.Font).Width;<br />
                int totalWidthLine = widthText + widthCurrentLine;<br />
                if (widthCurrentLine <= widthBorder && totalWidthLine <= widthBorder)<br />
                {<br />
                    if (sb.ToString() == "")<br />
                        sb.Append(text);<br />
                    else<br />
                        sb.Append(" " + text);<br />
                }<br />
                else<br />
                {<br />
                    sw.WriteLine(sb.Length.ToString());              <br />
                    allLines.Add(sb.ToString());<br />
                    firstWordNextLine = text;<br />
                    sb = new StringBuilder();<br />
                }<br />
            }<br />
<br />
            for (int i = 0; i <= allLines.Count - 1; i++)<br />
            {<br />
                this.richTextBox1.Text += allLines[i].ToString() + "\n";<br />
            }                   <br />
        }


how to solve my problem and where does my mistake in code ?
thanks
AnswerRe: Need an Algorithm like 'Word Wrap' in notepad. Pin
Giorgi Dalakishvili8-Sep-07 7:26
mentorGiorgi Dalakishvili8-Sep-07 7:26 
QuestionConsuming Java Web Service using C# Pin
arctix8-Sep-07 4:48
arctix8-Sep-07 4:48 
AnswerRe: Consuming Java Web Service using C# Pin
Guffa8-Sep-07 4:58
Guffa8-Sep-07 4:58 
QuestionRe: Consuming Java Web Service using C# [modified] Pin
arctix9-Sep-07 2:57
arctix9-Sep-07 2:57 
QuestionGenerics Problem Question Pin
PaulPrice8-Sep-07 4:44
PaulPrice8-Sep-07 4:44 
AnswerRe: Generics Problem Question Pin
Giorgi Dalakishvili8-Sep-07 4:49
mentorGiorgi Dalakishvili8-Sep-07 4:49 
GeneralRe: Generics Problem Question Pin
PaulPrice8-Sep-07 4:58
PaulPrice8-Sep-07 4:58 
GeneralRe: Generics Problem Question Pin
Giorgi Dalakishvili8-Sep-07 5:05
mentorGiorgi Dalakishvili8-Sep-07 5:05 
GeneralRe: Generics Problem Question Pin
PaulPrice8-Sep-07 5:11
PaulPrice8-Sep-07 5:11 
GeneralRe: Generics Problem Question Pin
Giorgi Dalakishvili8-Sep-07 5:18
mentorGiorgi Dalakishvili8-Sep-07 5:18 
QuestionAntivirus question Pin
sajid.salim.khan8-Sep-07 4:20
sajid.salim.khan8-Sep-07 4:20 
AnswerRe: Antivirus question Pin
Paul Conrad8-Sep-07 4:26
professionalPaul Conrad8-Sep-07 4:26 
QuestionDataGrid control WinFroms Pin
somagunasekaran8-Sep-07 4:19
somagunasekaran8-Sep-07 4:19 
AnswerRe: DataGrid control WinFroms Pin
Paul Conrad8-Sep-07 4:27
professionalPaul Conrad8-Sep-07 4:27 
QuestionRythm game Pin
pokabot8-Sep-07 3:08
pokabot8-Sep-07 3:08 
AnswerRe: Rythm game Pin
Guffa8-Sep-07 3:56
Guffa8-Sep-07 3:56 
GeneralRe: Rythm game Pin
pokabot8-Sep-07 4:35
pokabot8-Sep-07 4:35 

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.