作成日: 2026/06/24 最終更新日: 2026/06/24
文書種別
使用方法
詳細
データ検証によってエラーになったセルにエラーメッセージのツールチップが表示されているとき、マウス操作などでウィンドウの位置を移動すると、ツールチップは追従せずに、最初の表示位置にそのまま留まります。
ツールチップをウィンドウの移動に合わせて追従させることはできませんが、ウィンドウの移動のタイミングで一旦ツールチップを非表示にし、移動後に再度ツールチップを表示させることで対処することが可能です。
◎サンプルコード(VB)
ツールチップをウィンドウの移動に合わせて追従させることはできませんが、ウィンドウの移動のタイミングで一旦ツールチップを非表示にし、移動後に再度ツールチップを表示させることで対処することが可能です。
◎サンプルコード(VB)
Imports GrapeCity.Windows.SpreadGrid Imports System.Windows.Threading Private Sub GcSpreadGrid_CellEditEnding(sender As Object, e As GrapeCity.Windows.SpreadGrid.SpreadCellEditEndingEventArgs) Dim cell As CellPosition = e.CellPosition If (e.CellPosition.Column = 0 Or e.CellPosition.Column = 1) Then Dim EditValue As String = CType(GcSpreadGrid1.EditElement, TextBox).Text If (EditValue.Length >= 5) Then Dim msg As String = "5文字以上入力できません。" GcSpreadGrid1(cell).ValidationErrors.Add(New SpreadValidationError(msg, New Exception(msg))) End If End If End Sub Dim timer As DispatcherTimer = New DispatcherTimer Dim errors() As SpreadValidationError Private Sub Window_LocationChanged(sender As Object, e As EventArgs) If ((Not (GcSpreadGrid1.ActiveCell) Is Nothing) _ AndAlso (GcSpreadGrid1.ActiveCell.ValidationErrors.Count > 0)) Then errors = GcSpreadGrid1.ActiveCell.ValidationErrors.ToArray GcSpreadGrid1.ActiveCell.ValidationErrors.Clear() timer.Interval = New TimeSpan(0, 0, 1) AddHandler timer.Tick, AddressOf timer_Tick timer.Start() End If End Sub Private Sub timer_Tick(ByVal sender As Object, ByVal e As EventArgs) For Each err As SpreadValidationError In errors Me.GcSpreadGrid1.ActiveCell.ValidationErrors.Add(err) Next timer.Stop() End Sub◎サンプルコード(C#)
using GrapeCity.Windows.SpreadGrid;
using System.Windows.Threading;
private void GcSpreadGrid_CellEditEnding(object sender, GrapeCity.Windows.SpreadGrid.SpreadCellEditEndingEventArgs e)
{
CellPosition cell = e.CellPosition;
if (e.CellPosition.Column == 0 || e.CellPosition.Column == 1)
{
String EditValue = (gcSpreadGrid1.EditElement as TextBox).Text;
if (EditValue.Length >= 5)
{
string msg = "5文字以上入力できません。";
gcSpreadGrid1[cell].ValidationErrors.Add(new SpreadValidationError(msg, new Exception(msg)));
}
}
}
DispatcherTimer timer = new DispatcherTimer();
SpreadValidationError[] errors;
private void Window_LocationChanged(object sender, EventArgs e)
{
if (gcSpreadGrid1.ActiveCell != null && gcSpreadGrid1.ActiveCell.ValidationErrors.Count > 0)
{
errors = gcSpreadGrid1.ActiveCell.ValidationErrors.ToArray();
gcSpreadGrid1.ActiveCell.ValidationErrors.Clear();
timer.Interval = new TimeSpan(0, 0, 1);
timer.Tick += timer_Tick;
timer.Start();
}
}
void timer_Tick(object sender, EventArgs e)
{
foreach (SpreadValidationError err in errors)
{
this.gcSpreadGrid1.ActiveCell.ValidationErrors.Add(err);
}
timer.Stop();
}