PowerTools MultiRow for Windows Forms 8.0J
ErrorText プロパティ (CellPaintingEventArgs)
使用例 

セルで発生したエラーを示すエラーテキストを取得します。
構文
Public ReadOnly Property ErrorText As String
public string ErrorText {get;}

プロパティ値

セルで発生したエラーを示すエラーテキストを表すSystem.String値。
使用例
次のサンプルコードは、セルの描画ロジックをカスタマイズする方法を示します。このサンプルコードは、GcMultiRow.CellPaintingイベントに示されている詳細なコード例の一部を抜粋したものです。
void gcMultiRow_CellPainting(object sender, CellPaintingEventArgs e)
{
    if (e.CellIndex == 1 && e.Scope == CellScope.Row)
    {
        e.PaintBackground(e.ClipBounds);

        PaintRateBlock(e);

        e.PaintForeground(e.ClipBounds);

        e.PaintBorder(e.ClipBounds);

        // If you customize the paint logic, make sure, the Handled property should be set to true.
        e.Handled = true;
    }
}
private static void PaintRateBlock(CellPaintingEventArgs e)
{
    Color color1 = Color.Red;
    Color color2 = Color.Orange;
    if (e.Selected)
    {
        color1 = Color.Blue;
        color2 = Color.SkyBlue;
    }

    decimal rate = 0m;

    if (e.Value != null)
    {
        rate = (decimal)(e.Value) / 100m;
    }

    // Calculate block size.
    int spinButtonWidth = 17;
    int blockWidth = (int)((e.ClipBounds.Width - spinButtonWidth) * rate);

    if (blockWidth > 0)
    {
        Rectangle rect = e.CellBounds;

        rect.Width = blockWidth;

        LinearGradientBrush brush = new LinearGradientBrush(rect, color1, color2, LinearGradientMode.Vertical);

        e.Graphics.FillRectangle(brush, rect);
    }
}
Private Sub gcMultiRow_CellPainting(ByVal sender As Object, ByVal e As CellPaintingEventArgs) Handles gcMultiRow.CellPainting
    If e.CellIndex = 1 AndAlso e.Scope = CellScope.Row Then
        e.PaintBackground(e.ClipBounds)

        PaintRateBlock(e)

        e.PaintForeground(e.ClipBounds)

        e.PaintBorder(e.ClipBounds)

        ' If you customize the paint logic, make sure, the Handled property should be set to true.
        e.Handled = True
    End If
End Sub
Private Shared Sub PaintRateBlock(ByVal e As CellPaintingEventArgs)
    Dim color1 As Color = Color.Red
    Dim color2 As Color = Color.Orange
    If e.Selected Then
        color1 = Color.Blue
        color2 = Color.SkyBlue
    End If

    Dim rate As Decimal = 0D

    If e.Value <> Nothing Then
        rate = DirectCast((e.Value), Decimal) / 100D
    End If

    ' Calculate block size.
    Dim spinButtonWidth As Integer = 17
    Dim blockWidth As Integer = CInt((e.ClipBounds.Width - spinButtonWidth) * rate)

    If blockWidth > 0 Then
        Dim rect As Rectangle = e.CellBounds

        rect.Width = blockWidth

        Dim brush As New LinearGradientBrush(rect, color1, color2, LinearGradientMode.Vertical)

        e.Graphics.FillRectangle(brush, rect)
    End If
End Sub
参照

CellPaintingEventArgs クラス
CellPaintingEventArgs メンバ

 

 


© 2008-2015 GrapeCity inc. All rights reserved.