Click here to Skip to main content
15,892,809 members
Home / Discussions / C#
   

C#

 
QuestionGetting and Setting location of Dockable window Pin
kumar.bs27-May-07 18:23
kumar.bs27-May-07 18:23 
QuestionWriting in an embedded XML file Pin
xbiplav27-May-07 17:46
xbiplav27-May-07 17:46 
AnswerRe: Writing in an embedded XML file Pin
Christian Graus27-May-07 18:11
protectorChristian Graus27-May-07 18:11 
QuestionLock a textbox and richtextbox together Pin
simplicitylabs27-May-07 11:04
simplicitylabs27-May-07 11:04 
AnswerRe: Lock a textbox and richtextbox together Pin
Christian Graus27-May-07 11:57
protectorChristian Graus27-May-07 11:57 
GeneralRe: Lock a textbox and richtextbox together Pin
simplicitylabs27-May-07 12:19
simplicitylabs27-May-07 12:19 
GeneralRe: Lock a textbox and richtextbox together Pin
Christian Graus27-May-07 12:36
protectorChristian Graus27-May-07 12:36 
GeneralRe: Lock a textbox and richtextbox together Pin
simplicitylabs27-May-07 12:53
simplicitylabs27-May-07 12:53 
Ah, ok...I misunderstood what you were asking. See the code below that creates the line numbers in textbox1:

Here's the code that does the work:

private void updateNumberList()
{
    Point pos = new Point(0, 0);
    int firstIndex = richTextBox1.GetCharIndexFromPosition(pos);
    int firstLine = richTextBox1.GetLineFromCharIndex(firstIndex);

    pos.X = ClientRectangle.Width;
    pos.Y = ClientRectangle.Height;
    int lastIndex = richTextBox1.GetCharIndexFromPosition(pos);
    int lastLine = richTextBox1.GetLineFromCharIndex(lastIndex);

    pos = textBox1.GetPositionFromCharIndex(lastIndex);

    textBox1.Text = "";
    for (int i = firstLine; i <= lastLine; i++)
    {
        textBox1.Text += i + 1 + " \r\n";
    }
}


Here's the code that calls it:

private void richTextBox1_TextChanged(object sender, EventArgs e)
{
    updateNumberList();
}

GeneralRe: Lock a textbox and richtextbox together Pin
Christian Graus27-May-07 13:08
protectorChristian Graus27-May-07 13:08 
AnswerRe: Lock a textbox and richtextbox together Pin
Arun.Immanuel27-May-07 18:56
Arun.Immanuel27-May-07 18:56 
AnswerRe: Lock a textbox and richtextbox together Pin
mav.northwind27-May-07 23:08
mav.northwind27-May-07 23:08 
Questionfile extensions. Is there a way around hardcoding ? Pin
Ylno27-May-07 10:58
Ylno27-May-07 10:58 
AnswerRe: file extensions. Is there a way around hardcoding ? Pin
Christian Graus27-May-07 11:38
protectorChristian Graus27-May-07 11:38 
GeneralRe: file extensions. Is there a way around hardcoding ? Pin
Ylno27-May-07 11:46
Ylno27-May-07 11:46 
GeneralRe: file extensions. Is there a way around hardcoding ? Pin
Christian Graus27-May-07 11:56
protectorChristian Graus27-May-07 11:56 
AnswerRe: file extensions. Is there a way around hardcoding ? Pin
Luc Pattyn27-May-07 11:51
sitebuilderLuc Pattyn27-May-07 11:51 
GeneralRe: file extensions. Is there a way around hardcoding ? Pin
Christian Graus27-May-07 12:37
protectorChristian Graus27-May-07 12:37 
GeneralRe: file extensions. Is there a way around hardcoding ? Pin
Luc Pattyn27-May-07 13:18
sitebuilderLuc Pattyn27-May-07 13:18 
GeneralRe: file extensions. Is there a way around hardcoding ? Pin
Christian Graus27-May-07 14:13
protectorChristian Graus27-May-07 14:13 
GeneralRe: file extensions. Is there a way around hardcoding ? Pin
Ylno28-May-07 23:06
Ylno28-May-07 23:06 
QuestionTabStop Property Creating? Pin
İsmail Durmaz27-May-07 9:37
İsmail Durmaz27-May-07 9:37 
AnswerRe: TabStop Property Creating? Pin
Christian Graus27-May-07 11:54
protectorChristian Graus27-May-07 11:54 
GeneralRe: TabStop Property Creating? Pin
İsmail Durmaz27-May-07 11:59
İsmail Durmaz27-May-07 11:59 
QuestionHow to add more functionality to the &#8220;ChangePassword&#8221; control ? Pin
tedhill1327-May-07 9:19
tedhill1327-May-07 9:19 
QuestionList classList = new List(); Pin
sharp source27-May-07 7:18
sharp source27-May-07 7:18 

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.