PowerTools MultiRow for Windows Forms 8.0J
FreezeLines プロパティ
使用例 

GcMultiRowコントロールのすべての固定行のスタイルと色を取得または設定します。
構文
Public Property FreezeLines As FreezeLines
public FreezeLines FreezeLines {get; set;}

プロパティ値

GcMultiRowコントロールのすべての固定行のスタイルと色を表すFreezeLines。既定値はすべての固定行について黒の細い実線です。
解説

固定行機能を使用すると、特定のセルや行を常に表示された状態にすることができます。固定行は、FreezeTopRowCountFreezeBottomRowCountFreezeLeftCellIndexFreezeRightCellIndexなどのプロパティによって実現されます。

このプロパティを設定すると、各固定行のスタイルが変更されます。

使用例
次のサンプルコードは、行およびセルを固定する方法と、固定行の外観をカスタマイズする方法を示します。テストするには各ボタンをクリックします。
using System;
using System.Drawing;
using System.Windows.Forms;

namespace GrapeCity.Win.MultiRow.SampleCode
{
    public class FreezeDemo : Form
    {
        private GcMultiRow gcMultiRow1 = new GcMultiRow();
        private FlowLayoutPanel panel = new FlowLayoutPanel();

        public FreezeDemo()
        {
            this.Text = "Freeze Demo";
            this.Size = new Size(600, 350);

            // Initial flow layout panel and add to form.
            this.panel.Dock = DockStyle.Left;
            this.panel.Size = new Size(200, 200);
            this.panel.FlowDirection = FlowDirection.TopDown;
            this.panel.WrapContents = false;
            this.panel.Padding = new Padding(5);
            this.Controls.Add(panel);

            // Add MultiRow to form
            this.gcMultiRow1.Dock = DockStyle.Left;
            this.gcMultiRow1.Width = 400;
            this.Controls.Add(this.gcMultiRow1);

            // Tip label
            Label label = new Label();
            label.Height = 20;
            label.Dock = DockStyle.Bottom;
            label.BackColor = SystemColors.Info;
            label.Text = "Yow can try to click buttons and scroll MultiRow control. You will find the frozen area do not scroll.";
            this.Controls.Add(label);

            this.Load += new EventHandler(Form1_Load);

            InitButton();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // Create a grid like template with 10 columns. The cells in template will be named "textBoxCell1", "textBoxCell2"..."textBoxCell10".
            gcMultiRow1.Template = Template.CreateGridTemplate(10);
            gcMultiRow1.RowCount = 30;

            // Initialize cell value for MultiRow control.
            for (int i = 0; i < gcMultiRow1.RowCount; i++)
            {
                gcMultiRow1.SetValue(i, "textBoxCell1", i);
            }
        }

        #region Button Event Handlers

        void setTopFreezButton_Click(object sender, EventArgs e)
        {
            if (this.gcMultiRow1.FreezeTopRowCount == 0)
            {
                // Freeze some rows in top of gcMultiRow.
                this.gcMultiRow1.FreezeTopRowCount = 2;
            }
            else
            {
                // Unfreeze rows in top of gcMultiRow.
                this.gcMultiRow1.FreezeTopRowCount = 0;
            }
        }

        void setLeftFreezeButton_Click(object sender, EventArgs e)
        {
            // You can use FreezeLeftCellIndex instead of FreezeLeftCellName to indicate which cell will be frozen.
            if (string.IsNullOrEmpty(this.gcMultiRow1.FreezeLeftCellName))
            {
                // Freeze some rows in top of gcMultiRow.
                this.gcMultiRow1.FreezeLeftCellName = "textBoxCell1";
                // this.gcMultiRow1.FreezeLeftCellIndex = 0;
            }
            else
            {
                // Unfreeze rows in top of gcMultiRow.
                this.gcMultiRow1.FreezeLeftCellName = string.Empty;
                // this.gcMultiRow1.FreezeLeftCellIndex = -1;
            }
        }

        void setRightFreezeButton_Click(object sender, EventArgs e)
        {
            // You can use FreezeRightCellIndex instead of FreezeRightCellName to indicate which cell will be frozen.
            if (string.IsNullOrEmpty(this.gcMultiRow1.FreezeRightCellName))
            {
                // Freeze some rows in top of gcMultiRow.
                this.gcMultiRow1.FreezeRightCellName = "textBoxCell10";
                // this.gcMultiRow1.FreezeRightCellIndex = 0;
            }
            else
            {
                // Unfreeze rows in top of gcMultiRow.
                this.gcMultiRow1.FreezeRightCellName = string.Empty;
                // this.gcMultiRow1.FreezeRightCellIndex = -1;
            }
        }

        void setBottomFreezeButton_Click(object sender, EventArgs e)
        {
            if (this.gcMultiRow1.FreezeBottomRowCount == 0)
            {
                // Freeze some rows in bottom of gcMultiRow.
                this.gcMultiRow1.FreezeBottomRowCount = 2;
            }
            else
            {
                // Unfreeze rows in bottom of gcMultiRow.
                this.gcMultiRow1.FreezeBottomRowCount = 0;
            }
        }

        void setFreezeStyleButton_Click(object sender, EventArgs e)
        {
            FreezeLines freezeLines = this.gcMultiRow1.FreezeLines;

            if (this.gcMultiRow1.FreezeLines.All == new Line(LineStyle.Thin, Color.Black))
            {
                // set top freeze line to a thin red line.
                freezeLines.Top = new Line(LineStyle.Thin, Color.Red);
                // set top freeze line to a thin red line.
                freezeLines.Bottom = new Line(LineStyle.MediumDashed, Color.Green);
                // set top freeze line to a thin red line.
                freezeLines.Right = new Line(LineStyle.Double, Color.Blue);
                // hide left freeze line, but freeze behavior still take effect.
                freezeLines.Left = Line.Empty;
            }
            else
            {
                freezeLines.All = new Line(LineStyle.Thin, Color.Black);
            }

            this.gcMultiRow1.FreezeLines = freezeLines;
        }

        #endregion

        #region Initialize Buttons

        private void InitButton()
        {
            AddButton(setTopFreezButton, "Freeze/Unfreeze rows in top", new EventHandler(setTopFreezButton_Click));
            AddButton(setLeftFreezeButton, "Freeze/Unfreeze cell in left", new EventHandler(setLeftFreezeButton_Click));
            AddButton(setRightFreezeButton, "Freeze/Unfreeze cell in right", new EventHandler(setRightFreezeButton_Click));
            AddButton(setBottomFreezeButton, "Freeze/Unfreeze rows in bottom", new EventHandler(setBottomFreezeButton_Click));
            AddButton(setFreezeStyleButton, "Change freeze style appearance", new EventHandler(setFreezeStyleButton_Click));
        }

        private void AddButton(Button button, string text, EventHandler eventHandler)
        {
            this.panel.Controls.Add(button);
            button.Text = text;
            button.AutoSize = true;
            button.Click += eventHandler;
        }

        Button setTopFreezButton = new Button();
        Button setLeftFreezeButton = new Button();
        Button setRightFreezeButton = new Button();
        Button setBottomFreezeButton = new Button();
        Button setFreezeStyleButton = new Button();

        #endregion

        [STAThreadAttribute()]
        public static void Main()
        {
            Application.EnableVisualStyles();
            Application.Run(new FreezeDemo());
        }
    }
}
Imports System
Imports System.Drawing
Imports System.Windows.Forms
Imports GrapeCity.Win.MultiRow

Public Class FreezeDemo
    Inherits Form
    Private gcMultiRow1 As New GcMultiRow()
    Private panel As New FlowLayoutPanel()

    Public Sub New()
        Me.Text = "Freeze Demo"
        Me.Size = New Size(600, 350)

        ' Initial flow layout panel and add to form.
        Me.panel.Dock = DockStyle.Left
        Me.panel.Size = New Size(200, 200)
        Me.panel.FlowDirection = FlowDirection.TopDown
        Me.panel.WrapContents = False
        Me.panel.Padding = New Padding(5)
        Me.Controls.Add(panel)

        ' Add MultiRow to form
        Me.gcMultiRow1.Dock = DockStyle.Left
        Me.gcMultiRow1.Width = 400
        Me.Controls.Add(Me.gcMultiRow1)

        ' Tip label
        Dim label As New Label()
        label.Height = 20
        label.Dock = DockStyle.Bottom
        label.BackColor = SystemColors.Info
        label.Text = "Yow can try to click buttons and scroll MultiRow control. You will find the frozen area do not scroll."
        Me.Controls.Add(label)
        InitButton()
    End Sub

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        ' Create a grid like template with 10 columns. The cells in template will be named "textBoxCell1", "textBoxCell2"..."textBoxCell10".
        gcMultiRow1.Template = Template.CreateGridTemplate(10)
        gcMultiRow1.RowCount = 30

        ' Initialize cell value for MultiRow control.

        For i As Integer = 0 To gcMultiRow1.RowCount - 1
            gcMultiRow1.SetValue(i, "textBoxCell1", i)
        Next
    End Sub

#Region "Button Event Handlers"

    Private Sub setTopFreezButton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles setTopFreezButton.Click
        If Me.gcMultiRow1.FreezeTopRowCount = 0 Then
            ' Freeze some rows in top of gcMultiRow.
            Me.gcMultiRow1.FreezeTopRowCount = 2
        Else
            ' Unfreeze rows in top of gcMultiRow.
            Me.gcMultiRow1.FreezeTopRowCount = 0
        End If
    End Sub

    Private Sub setLeftFreezeButton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles setLeftFreezeButton.Click
        ' You can use FreezeLeftCellIndex instead of FreezeLeftCellName to indicate which cell will be frozen.
        If String.IsNullOrEmpty(Me.gcMultiRow1.FreezeLeftCellName) Then
            ' Freeze some rows in top of gcMultiRow.
            ' this.gcMultiRow1.FreezeLeftCellIndex = 0;
            Me.gcMultiRow1.FreezeLeftCellName = "textBoxCell1"
        Else
            ' Unfreeze rows in top of gcMultiRow.
            ' this.gcMultiRow1.FreezeLeftCellIndex = -1;
            Me.gcMultiRow1.FreezeLeftCellName = String.Empty
        End If
    End Sub

    Private Sub setRightFreezeButton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles setRightFreezeButton.Click
        ' You can use FreezeRightCellIndex instead of FreezeRightCellName to indicate which cell will be frozen.
        If String.IsNullOrEmpty(Me.gcMultiRow1.FreezeRightCellName) Then
            ' Freeze some rows in top of gcMultiRow.
            ' this.gcMultiRow1.FreezeRightCellIndex = 0;
            Me.gcMultiRow1.FreezeRightCellName = "textBoxCell10"
        Else
            ' Unfreeze rows in top of gcMultiRow.
            ' this.gcMultiRow1.FreezeRightCellIndex = -1;
            Me.gcMultiRow1.FreezeRightCellName = String.Empty
        End If
    End Sub

    Private Sub setBottomFreezeButton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles setBottomFreezeButton.Click
        If Me.gcMultiRow1.FreezeBottomRowCount = 0 Then
            ' Freeze some rows in bottom of gcMultiRow.
            Me.gcMultiRow1.FreezeBottomRowCount = 2
        Else
            ' Unfreeze rows in bottom of gcMultiRow.
            Me.gcMultiRow1.FreezeBottomRowCount = 0
        End If
    End Sub

    Private Sub setFreezeStyleButton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles setFreezeStyleButton.Click
        Dim freezeLines As FreezeLines = Me.gcMultiRow1.FreezeLines

        If Me.gcMultiRow1.FreezeLines.All = New Line(LineStyle.Thin, Color.Black) Then
            ' set top freeze line to a thin red line.
            freezeLines.Top = New Line(LineStyle.Thin, Color.Red)
            ' set top freeze line to a thin red line.
            freezeLines.Bottom = New Line(LineStyle.MediumDashed, Color.Green)
            ' set top freeze line to a thin red line.
            freezeLines.Right = New Line(LineStyle.Double, Color.Blue)
            ' hide left freeze line, but freeze behavior still take effect.
            freezeLines.Left = Line.Empty
        Else
            freezeLines.All = New Line(LineStyle.Thin, Color.Black)
        End If

        Me.gcMultiRow1.FreezeLines = freezeLines
    End Sub

#End Region

#Region "Initialize Buttons"

    Private Sub InitButton()
        AddButton(setTopFreezButton, "Freeze/Unfreeze rows in top")
        AddButton(setLeftFreezeButton, "Freeze/Unfreeze cell in left")
        AddButton(setRightFreezeButton, "Freeze/Unfreeze cell in right")
        AddButton(setBottomFreezeButton, "Freeze/Unfreeze rows in bottom")
        AddButton(setFreezeStyleButton, "Change freeze style appearance")
    End Sub

    Private Sub AddButton(ByVal button As Button, ByVal text As String)
        Me.panel.Controls.Add(button)
        button.Text = text
        button.AutoSize = True
    End Sub

    Friend WithEvents setTopFreezButton As New Button()
    Friend WithEvents setLeftFreezeButton As New Button()
    Friend WithEvents setRightFreezeButton As New Button()
    Friend WithEvents setBottomFreezeButton As New Button()
    Friend WithEvents setFreezeStyleButton As New Button()

#End Region

    <STAThreadAttribute()> _
    Public Shared Sub Main()
        Application.EnableVisualStyles()
        Application.Run(New FreezeDemo())
    End Sub
End Class
参照

GcMultiRow クラス
GcMultiRow メンバ
FreezeTopRowCount プロパティ
FreezeBottomRowCount プロパティ
FreezeLeftCellIndex プロパティ
FreezeLeftCellName プロパティ
FreezeRightCellIndex プロパティ
FreezeRightCellName プロパティ

 

 


© 2008-2015 GrapeCity inc. All rights reserved.