次のサンプルコードは、
TextBoxCellの持ついくつかの重要なプロパティを示します。このセルにテキスト全体を表示できない場合は、省略記号文字列"......"が表示されます。
HighlightTextが
trueに設定されているため、編集モードに入るとテキストが強調表示されます。また、
MaxLengthが10に設定されているため、元のテキストを削除して別のテキストを入力する場合、入力できる文字数は10文字に制限されます。
using System;
using System.Windows.Forms;
using System.Drawing;
namespace GrapeCity.Win.MultiRow.SampleCode
{
public class TextBoxCellDemo : Form
{
private GcMultiRow gcMultiRow1 = new GcMultiRow();
[STAThreadAttribute()]
public static void Main()
{
Application.EnableVisualStyles();
Application.Run(new TextBoxCellDemo());
}
public TextBoxCellDemo()
{
this.gcMultiRow1.Dock = DockStyle.Fill;
this.Text = "TextBoxCell Demo";
this.Controls.Add(this.gcMultiRow1);
this.Load += new EventHandler(Form1_Load);
this.Size = new Size(400, 350);
}
private void Form1_Load(object sender, EventArgs e)
{
TextBoxCell textBoxCell1 = new TextBoxCell();
//If the text cannot display completely, one '......' string will be shown at the text's end, hover the cell, the whole text will be shown in tool tip.
textBoxCell1.Ellipsis = MultiRowEllipsisMode.EllipsisEnd;
textBoxCell1.EllipsisString = "......";
//Enter the edit mode, the text will be highlight selected.
textBoxCell1.HighlightText = true;
textBoxCell1.Value = "DELETE THIS STRING TO INPUT BY YOURSELF, ONLY 10 CHARACTERS CAN BE INPUT";
textBoxCell1.MaxLength = 10;
//The value will be casted to lower case.
textBoxCell1.CharacterCasing = CharacterCasing.Lower;
TextBoxCell textBoxCell2 = new TextBoxCell();
//Input text in textBoxCell2, it will be treated as password, always display '#'.
textBoxCell2.PasswordChar = '#';
textBoxCell2.UseSystemPasswordChar = false;
textBoxCell2.Value = "12345";
Template template1 = Template.CreateGridTemplate(new Cell[] { textBoxCell1, textBoxCell2 }, 160,
AutoGenerateGridTemplateStyles.ColumnHeader | AutoGenerateGridTemplateStyles.RowHeaderAutoNumber);
gcMultiRow1.Template = template1;
gcMultiRow1.RowCount = 3;
}
}
}
Imports System
Imports System.Windows.Forms
Imports System.Drawing
Imports GrapeCity.Win.MultiRow
Public Class TextBoxCellDemo
Inherits Form
Private gcMultiRow1 As New GcMultiRow()
Public Sub New()
Me.gcMultiRow1.Dock = DockStyle.Fill
Me.Text = "TextBoxCell Demo"
Me.Controls.Add(Me.gcMultiRow1)
Me.Size = New Size(400, 350)
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim textBoxCell1 As New TextBoxCell()
'If the text cannot display completely, one '......' string will be shown at the text's end, hover the cell, the whole text will be shown in tool tip.
textBoxCell1.Ellipsis = MultiRowEllipsisMode.EllipsisEnd
textBoxCell1.EllipsisString = "......"
'Enter the edit mode, the text will be highlight selected.
textBoxCell1.HighlightText = True
textBoxCell1.Value = "DELETE THIS STRING TO INPUT BY YOURSELF, ONLY 10 CHARACTERS CAN BE INPUT"
textBoxCell1.MaxLength = 10
'The value will be casted to lower case.
textBoxCell1.CharacterCasing = CharacterCasing.Lower
Dim textBoxCell2 As New TextBoxCell()
'Input text in textBoxCell2, it will be treated as password, always display '#'.
textBoxCell2.PasswordChar = "#"c
textBoxCell2.UseSystemPasswordChar = False
textBoxCell2.Value = "12345"
Dim template1 As Template = Template.CreateGridTemplate(New Cell() {textBoxCell1, textBoxCell2})
gcMultiRow1.Template = template1
gcMultiRow1.RowCount = 3
End Sub
<STAThreadAttribute()> _
Public Shared Sub Main()
Application.EnableVisualStyles()
Application.Run(New TextBoxCellDemo())
End Sub
End Class