次のサンプルコードは、
CalendarTextBoxCellType のいくつかの重要なプロパティを示します。セルにテキスト全体を表示できない場合、省略記号文字列 "......" が表示されます。
HighlightText プロパティが
true に設定されているため、編集モードに入るとテキストが選択されます。
MaxLength は 10 なので、元のテキストを削除してテキストを入力する場合、10 文字だけ入力できます。
using System;
using System.Windows.Forms;
using System.Drawing;
using System.Collections.Generic;
using GrapeCity.Win.CalendarGrid;
namespace CalendarGridSampleCode
{
public class TextBoxCellDemo : Form
{
private GcCalendarGrid gcCalendarGrid1 = new GcCalendarGrid();
[STAThreadAttribute()]
public static void Main()
{
Application.EnableVisualStyles();
Application.Run(new TextBoxCellDemo());
}
public TextBoxCellDemo()
{
this.gcCalendarGrid1.Dock = DockStyle.Fill;
this.Text = "TextBoxCell Demo";
this.Controls.Add(this.gcCalendarGrid1);
this.Load += Form1_Load;
this.Size = new Size(500, 500);
}
private void Form1_Load(object sender, EventArgs e)
{
CalendarTextBoxCellType textBoxCell1 = new CalendarTextBoxCellType();
//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 = CalendarGridEllipsisMode.EllipsisEnd;
textBoxCell1.EllipsisString = "......";
//Enter the edit mode, the text will be highlight selected.
textBoxCell1.HighlightText = true;
textBoxCell1.MaxLength = 10;
//The value will be casted to lower case.
textBoxCell1.CharacterCasing = CharacterCasing.Lower;
CalendarTextBoxCellType textBoxCell2 = new CalendarTextBoxCellType();
//Input text in textBoxCell2, it will be treated as password, always display '#'.
textBoxCell2.PasswordChar = '#';
textBoxCell2.UseSystemPasswordChar = false;
CalendarTemplate template1 = CalendarTemplate.CreateDefaultTemplate();
template1.Content[1, 0].CellType = textBoxCell1;
template1.Content[1, 0].Value = "DELETE THIS STRING TO INPUT BY YOURSELF, ONLY 10 CHARACTERS CAN BE INPUT";
template1.Content[2, 0].CellType = textBoxCell2;
template1.Content[2, 0].Value = "12345";
gcCalendarGrid1.Template = template1;
}
}
}
Imports System.Windows.Forms
Imports System.Drawing
Imports System.Collections.Generic
Imports GrapeCity.Win.CalendarGrid
Namespace CalendarGridSampleCode
Public Class TextBoxCellDemo
Inherits Form
Private gcCalendarGrid1 As New GcCalendarGrid()
<STAThreadAttribute> _
Public Shared Sub Main()
Application.EnableVisualStyles()
Application.Run(New TextBoxCellDemo())
End Sub
Public Sub New()
Me.gcCalendarGrid1.Dock = DockStyle.Fill
Me.Text = "TextBoxCell Demo"
Me.Controls.Add(Me.gcCalendarGrid1)
AddHandler Me.Load, AddressOf Form1_Load
Me.Size = New Size(500, 500)
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs)
Dim textBoxCell1 As New CalendarTextBoxCellType()
'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 = CalendarGridEllipsisMode.EllipsisEnd
textBoxCell1.EllipsisString = "......"
'Enter the edit mode, the text will be highlight selected.
textBoxCell1.HighlightText = True
textBoxCell1.MaxLength = 10
'The value will be casted to lower case.
textBoxCell1.CharacterCasing = CharacterCasing.Lower
Dim textBoxCell2 As New CalendarTextBoxCellType()
'Input text in textBoxCell2, it will be treated as password, always display '#'.
textBoxCell2.PasswordChar = "#"c
textBoxCell2.UseSystemPasswordChar = False
Dim template1 As CalendarTemplate = CalendarTemplate.CreateDefaultTemplate()
template1.Content(1, 0).CellType = textBoxCell1
template1.Content(1, 0).Value = "DELETE THIS STRING TO INPUT BY YOURSELF, ONLY 10 CHARACTERS CAN BE INPUT"
template1.Content(2, 0).CellType = textBoxCell2
template1.Content(2, 0).Value = "12345"
gcCalendarGrid1.Template = template1
End Sub
End Class
End Namespace