作成日: 2019/08/05 最終更新日: 2019/08/05
文書種別
使用方法
詳細
FlexGridには、セルのテキストや画像を点滅させるための組み込みの機能は用意されていません。
代替方法として、Timerコントロールを使用し、そのTickイベント内でテキストの色、または画像の表示/非表示を交互に切り替える方法が考えられます。
◎サンプルコード(VB)
◎サンプルコード(C#)
代替方法として、Timerコントロールを使用し、そのTickイベント内でテキストの色、または画像の表示/非表示を交互に切り替える方法が考えられます。
◎サンプルコード(VB)
Imports C1.Win.C1FlexGrid
Public Class Form1
Dim cs As C1.Win.C1FlexGrid.CellStyle
Dim bImg As Boolean
Dim img As Image = Image.FromFile("..¥..¥test.gif")
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' データの設定
Dim i As Integer
For i = 1 To C1FlexGrid1.Rows.Count - 1
C1FlexGrid1(i, 1) = "AA " + i.ToString()
Next
' セルスタイルの設定
cs = C1FlexGrid1.Styles.Add("Blinker")
cs.ForeColor = Color.Black
C1FlexGrid1.Cols(1).Style = cs
' イメージ設定
C1FlexGrid1.SetCellImage(1, 2, img)
bImg = False
' タイマーの設定
Timer1.Interval = 500
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
' 文字色の切り替え
If cs.ForeColor.Equals(Color.Black) Then
cs.ForeColor = Color.White
Else
cs.ForeColor = Color.Black
End If
' イメージ表示の切り替え
If bImg = True Then
C1FlexGrid1.SetCellImage(1, 2, img)
Else
C1FlexGrid1.SetCellImage(1, 2, Nothing)
End If
bImg = Not (bImg)
End Sub
End Class
Public Class Form1
Dim cs As C1.Win.C1FlexGrid.CellStyle
Dim bImg As Boolean
Dim img As Image = Image.FromFile("..¥..¥test.gif")
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' データの設定
Dim i As Integer
For i = 1 To C1FlexGrid1.Rows.Count - 1
C1FlexGrid1(i, 1) = "AA " + i.ToString()
Next
' セルスタイルの設定
cs = C1FlexGrid1.Styles.Add("Blinker")
cs.ForeColor = Color.Black
C1FlexGrid1.Cols(1).Style = cs
' イメージ設定
C1FlexGrid1.SetCellImage(1, 2, img)
bImg = False
' タイマーの設定
Timer1.Interval = 500
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
' 文字色の切り替え
If cs.ForeColor.Equals(Color.Black) Then
cs.ForeColor = Color.White
Else
cs.ForeColor = Color.Black
End If
' イメージ表示の切り替え
If bImg = True Then
C1FlexGrid1.SetCellImage(1, 2, img)
Else
C1FlexGrid1.SetCellImage(1, 2, Nothing)
End If
bImg = Not (bImg)
End Sub
End Class
◎サンプルコード(C#)
using C1.Win.C1FlexGrid;
namespace C1FlexGrid_Blinker
{
public partial class Form1 : Form
{
C1.Win.C1FlexGrid.CellStyle cs;
bool bImg;
Image img = Image.FromFile("..¥¥..¥¥test.gif");
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// データの設定
for (int i = 1; (i <= (c1FlexGrid1.Rows.Count - 1)); i++)
{
c1FlexGrid1[i, 1] = ("AA " + i.ToString());
}
// セルスタイルの設定
cs = c1FlexGrid1.Styles.Add("Blinker");
cs.ForeColor = Color.Black;
c1FlexGrid1.Cols[1].Style = cs;
// イメージ設定
c1FlexGrid1.SetCellImage(1, 2, img);
bImg = false;
// タイマーの設定
timer1.Interval = 500;
timer1.Enabled = true;
}
private void timer1_Tick(object sender, EventArgs e)
{
// 文字色の切り替え
if (cs.ForeColor.Equals(Color.Black))
{
cs.ForeColor = Color.White;
}
else
{
cs.ForeColor = Color.Black;
}
// イメージ表示の切り替え
if ((bImg == true))
{
c1FlexGrid1.SetCellImage(1, 2, img);
}
else
{
c1FlexGrid1.SetCellImage(1, 2, null);
}
bImg = !bImg;
}
}
}
namespace C1FlexGrid_Blinker
{
public partial class Form1 : Form
{
C1.Win.C1FlexGrid.CellStyle cs;
bool bImg;
Image img = Image.FromFile("..¥¥..¥¥test.gif");
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// データの設定
for (int i = 1; (i <= (c1FlexGrid1.Rows.Count - 1)); i++)
{
c1FlexGrid1[i, 1] = ("AA " + i.ToString());
}
// セルスタイルの設定
cs = c1FlexGrid1.Styles.Add("Blinker");
cs.ForeColor = Color.Black;
c1FlexGrid1.Cols[1].Style = cs;
// イメージ設定
c1FlexGrid1.SetCellImage(1, 2, img);
bImg = false;
// タイマーの設定
timer1.Interval = 500;
timer1.Enabled = true;
}
private void timer1_Tick(object sender, EventArgs e)
{
// 文字色の切り替え
if (cs.ForeColor.Equals(Color.Black))
{
cs.ForeColor = Color.White;
}
else
{
cs.ForeColor = Color.Black;
}
// イメージ表示の切り替え
if ((bImg == true))
{
c1FlexGrid1.SetCellImage(1, 2, img);
}
else
{
c1FlexGrid1.SetCellImage(1, 2, null);
}
bImg = !bImg;
}
}
}
旧文書番号
84354