Click here to Skip to main content
16,004,890 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to do notepad with C# ? Pin
Christian Graus30-Jul-06 11:21
protectorChristian Graus30-Jul-06 11:21 
AnswerRe: How to do notepad with C# ? Pin
Colin Angus Mackay29-Jul-06 23:04
Colin Angus Mackay29-Jul-06 23:04 
QuestionRe: How to do notepad with C# ? Pin
nguyenquang028430-Jul-06 2:40
nguyenquang028430-Jul-06 2:40 
AnswerRe: How to do notepad with C# ? Pin
Colin Angus Mackay30-Jul-06 2:52
Colin Angus Mackay30-Jul-06 2:52 
AnswerRe: How to do notepad with C# ? Pin
Shy Agam29-Jul-06 23:06
Shy Agam29-Jul-06 23:06 
GeneralRe: How to do notepad with C# ? Pin
nguyenquang028430-Jul-06 2:37
nguyenquang028430-Jul-06 2:37 
QuestionRe: How to do notepad with C# ? Pin
nguyenquang028430-Jul-06 2:45
nguyenquang028430-Jul-06 2:45 
AnswerRe: How to do notepad with C# ? Pin
Shy Agam30-Jul-06 5:46
Shy Agam30-Jul-06 5:46 
If you want to display a dialog box upon an "Open" menu item, you don't need to catch the TextChange event of the textbox...
What you want to do is catch the Click event of the menu item, and display the dialog through there.

And just a little tip... Applications with an "Open" buttons, usually show the dialog prior to asking whether changes should be saved.
If the user selects a file, and presses the "OK" button or "Open" or whatever, then you display a messagebox prompting for saving changes.
If the user presses the cancel button in the "Open" dialog, you just do nothing.

As for your function...
There's no built in function in a textbox that gives you the ability to jump to a specified line.
Therefore, try using the following:
private void JumpToLine(int line)
{
    int position = -1;
    int currLine = 0;

    while ((position = textBox1.Text.IndexOf('\n', position + 1)) > 0 && currLine++ < line) ;

    // If there is not such line, exit the function
    if (position == -1) return;

    textBox1.SelectionStart = position;
    textBox1.Focus();
}
Notice the semicolon (";") after the "while" statement.
GeneralRe: How to do notepad with C# ? Pin
nguyenquang028430-Jul-06 6:16
nguyenquang028430-Jul-06 6:16 
QuestionException Windows - IDE Pin
AJ12329-Jul-06 22:14
AJ12329-Jul-06 22:14 
Questionhow to add logo in live video stream Pin
duaaali29-Jul-06 21:50
duaaali29-Jul-06 21:50 
Questionkeep parent form in background until child form closes Pin
tiburonium29-Jul-06 20:52
tiburonium29-Jul-06 20:52 
AnswerRe: keep parent form in background until child form closes Pin
stancrm29-Jul-06 21:10
stancrm29-Jul-06 21:10 
QuestionShallow vs Deep copy and arrays of classes Pin
kozu29-Jul-06 18:37
kozu29-Jul-06 18:37 
AnswerRe: Shallow vs Deep copy and arrays of classes Pin
Guffa29-Jul-06 22:58
Guffa29-Jul-06 22:58 
QuestionConditional testing data records for webpage display Pin
antar00729-Jul-06 17:54
antar00729-Jul-06 17:54 
QuestionVisual Studio 2005 Question Pin
rittjc29-Jul-06 15:08
rittjc29-Jul-06 15:08 
AnswerRe: Visual Studio 2005 Question Pin
Christian Graus29-Jul-06 15:16
protectorChristian Graus29-Jul-06 15:16 
GeneralRe: Visual Studio 2005 Question Pin
rittjc29-Jul-06 15:33
rittjc29-Jul-06 15:33 
GeneralRe: Visual Studio 2005 Question Pin
Christian Graus29-Jul-06 15:37
protectorChristian Graus29-Jul-06 15:37 
GeneralRe: Visual Studio 2005 Question Pin
rittjc29-Jul-06 16:47
rittjc29-Jul-06 16:47 
AnswerRe: Visual Studio 2005 Question Pin
Ed.Poore29-Jul-06 21:38
Ed.Poore29-Jul-06 21:38 
GeneralRe: Visual Studio 2005 Question Pin
rittjc30-Jul-06 5:19
rittjc30-Jul-06 5:19 
GeneralRe: Visual Studio 2005 Question Pin
Ed.Poore30-Jul-06 8:34
Ed.Poore30-Jul-06 8:34 
QuestionExternal Sorting Pin
Abbas Ali Butt29-Jul-06 12:49
Abbas Ali Butt29-Jul-06 12:49 

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.