GrapeCity CalendarGrid for Windows Forms 2.0J
ボタンのクリック処理をする

クリックイベントの処理

Button型セルをクリックすると、GcCalendarGrid.CellContentButtonClickイベントが発生します。CellContentButtonClickイベントを使用すると、Button型セルのクリックを処理できます。

Imports GrapeCity.Win.CalendarGrid

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Dim today As DateTime = DateTime.Today
    Dim buttonCellType As New CalendarButtonCellType()
    GcCalendarGrid1.Content(today).Rows(1).Cells(0).CellType = buttonCellType.Clone()
    GcCalendarGrid1.Content(today).Rows(1).Cells(0).Value = "ボタン"

    AddHandler GcCalendarGrid1.CellContentButtonClick, AddressOf GcCalendarGrid1_CellContentButtonClick
End Sub

Private Sub GcCalendarGrid1_CellContentButtonClick(sender As Object, e As CalendarCellEventArgs)
    MessageBox.Show(String.Format("クリックされたセル : {0}", e.CellPosition.ToString()))
End Sub
using GrapeCity.Win.CalendarGrid;

private void Form1_Load(object sender, EventArgs e)
{
    var today = DateTime.Today;
    var buttonCellType = new CalendarButtonCellType();
    gcCalendarGrid1.Content[today].Rows[1].Cells[0].CellType = buttonCellType.Clone();
    gcCalendarGrid1.Content[today].Rows[1].Cells[0].Value = "ボタン";

    gcCalendarGrid1.CellContentButtonClick += gcCalendarGrid1_CellContentButtonClick;
}

private void gcCalendarGrid1_CellContentButtonClick(object sender, CalendarCellEventArgs e)
{
    MessageBox.Show(string.Format("クリックされたセル : {0}", e.CellPosition.ToString()));
}


ボタンの無効化

ボタンのクリックを無効化するには、セルのEnabledプロパティをFalseに設定します。

Imports GrapeCity.Win.CalendarGrid

Dim today As DateTime = DateTime.Today
Dim buttonCellType As New CalendarButtonCellType()

GcCalendarGrid1.Content(today).Rows(1).Cells(0).Enabled = False
GcCalendarGrid1.Content(today).Rows(1).Cells(0).Value = "Click Me"
GcCalendarGrid1.Content(today).Rows(1).Cells(0).CellType = buttonCellType.Clone()
GcCalendarGrid1.ScrollIntoView(today)
using GrapeCity.Win.CalendarGrid;

var today = DateTime.Today;
var buttonCellType = new CalendarButtonCellType();

gcCalendarGrid1.Content[today].Rows[1].Cells[0].Enabled = false;
gcCalendarGrid1.Content[today].Rows[1].Cells[0].Value = "Click Me";
gcCalendarGrid1.Content[today].Rows[1].Cells[0].CellType = buttonCellType.Clone();
gcCalendarGrid1.ScrollIntoView(today);
参照

 

 


© 2008 GrapeCity inc. All rights reserved.