Count lines in the TextBox and read text in TextBox line by line : TextBox « GUI Windows Forms « C# / CSharp Tutorial

C# / CSharp Tutorial
1. Language Basics
2. Data Type
3. Operator
4. Statement
5. String
6. struct
7. Class
8. Operator Overload
9. delegate
10. Attribute
11. Data Structure
12. Assembly
13. Date Time
14. Development
15. File Directory Stream
16. Preprocessing Directives
17. Regular Expression
18. Generic
19. Reflection
20. Thread
21. I18N Internationalization
22. GUI Windows Forms
23. 2D
24. Design Patterns
25. Windows
26. XML
27. ADO.Net
28. Network
29. Directory Services
30. Security
31. unsafe
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
C# / CSharp Tutorial » GUI Windows Forms » TextBox 
22. 17. 7. Count lines in the TextBox and read text in TextBox line by line
Count lines in the TextBox and read text in TextBox line by line
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void showLinesButton_Click(object sender, EventArgs e)
    {
        StringBuilder lineInfo = new StringBuilder();
        lineInfo.Append("There are " + multiLineBox.Lines.Length.ToString() " lines.\n");
        foreach (string line in multiLineBox.Lines)
        {
            lineInfo.Append(line + "\n");
        }

        MessageBox.Show(lineInfo.ToString());
    }
}
partial class Form1
{
    private void InitializeComponent()
    {
        this.multiLineBox = new System.Windows.Forms.TextBox();
        this.showLinesButton = new System.Windows.Forms.Button();
        this.SuspendLayout();
        // 
        // multiLineBox
        // 
        this.multiLineBox.Location = new System.Drawing.Point(1212);
        this.multiLineBox.Multiline = true;
        this.multiLineBox.Name = "multiLineBox";
        this.multiLineBox.Size = new System.Drawing.Size(268213);
        this.multiLineBox.TabIndex = 0;
        // 
        // showLinesButton
        // 
        this.showLinesButton.Location = new System.Drawing.Point(205231);
        this.showLinesButton.Name = "showLinesButton";
        this.showLinesButton.Size = new System.Drawing.Size(7523);
        this.showLinesButton.TabIndex = 1;
        this.showLinesButton.Text = "Show Lines";
        this.showLinesButton.Click += new System.EventHandler(this.showLinesButton_Click);
        // 
        // Form1
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F13F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(292266);
        this.Controls.Add(this.showLinesButton);
        this.Controls.Add(this.multiLineBox);
        this.Name = "Form1";
        this.Text = "Form1";
        this.ResumeLayout(false);
        this.PerformLayout();

    }

    private System.Windows.Forms.TextBox multiLineBox;
    private System.Windows.Forms.Button showLinesButton;
}
public class TextBoxLineCountText
{
    [STAThread]
    static void Main()
    {
        Application.EnableVisualStyles();
        Application.Run(new Form1());
    }
}
22. 17. TextBox
22. 17. 1. Get input value from TextBox and display it vis a messagebox
22. 17. 2. TextBox key pressed event
22. 17. 3. TextBox Modified and TextChangedTextBox Modified and TextChanged
22. 17. 4. TextBox: Multiline and BorderStyleTextBox: Multiline and BorderStyle
22. 17. 5. TextBox Keyevent handerTextBox Keyevent hander
22. 17. 6. TextBox cancel eventTextBox cancel event
22. 17. 7. Count lines in the TextBox and read text in TextBox line by lineCount lines in the TextBox and read text in TextBox line by line
22. 17. 8. TextBox selectionTextBox selection
22. 17. 9. TextBox validationTextBox validation
22. 17. 10. Add ContextMenu to TextBoxAdd ContextMenu to TextBox
22. 17. 11. Use Regular Expression to Check the input for a TextBoxUse Regular Expression to Check the input for a TextBox
22. 17. 12. Multiline TextBoxMultiline TextBox
ww__w___._j___a__va___2s___.___c___o__m | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.