TextBox.Lines : TextBox « System.Windows.Forms « C# / C Sharp by API






TextBox.Lines

  

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(12, 12);
        this.multiLineBox.Multiline = true;
        this.multiLineBox.Name = "multiLineBox";
        this.multiLineBox.Size = new System.Drawing.Size(268, 213);
        this.multiLineBox.TabIndex = 0;
        // 
        // showLinesButton
        // 
        this.showLinesButton.Location = new System.Drawing.Point(205, 231);
        this.showLinesButton.Name = "showLinesButton";
        this.showLinesButton.Size = new System.Drawing.Size(75, 23);
        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(6F, 13F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(292, 266);
        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());
    }
}

   
    
  








Related examples in the same category

1.TextBox.AcceptsTab
2.TextBox.Anchor
3.TextBox.BorderStyle
4.TextBox.CanFocus
5.TextBox.Clear()
6.TextBox.Click
7.TextBox.ContextMenu
8.TextBox.ContainsFocus
9.TextBox.DataBindings
10.TextBox.DoDragDrop
11.TextBox.DragDrop
12.TextBox.DragEnter
13.TextBox.Focus()
14.TextBox.Focused
15.TextBox.GotFocus
16.TextBox.KeyPress
17.TextBox.LostFocus
18.TextBox.Multiline
19.TextBox.MouseDown
20.TextBox.PasswordChar
21.TextBox.ScrollBars
22.TextBox.SelectAll()
23.TextBox.SelectedText
24.TextBox.SelectionLength
25.TextBox.TextChanged
26.TextBox.Validated
27.TextBox.Validating