PowerTools MultiRow for Windows Forms 8.0J
Border クラス
メンバ  使用例 

矩形の境界線を表します。このクラスは、各辺に対応する4つのLineオブジェクトと、対角線に対応する2つのLineオブジェクトを格納します。
構文
Public Class Border 
   Inherits BorderBase
public class Border : BorderBase 
使用例
次のサンプルコードは、CellまたはSectionの境界線のスタイルと色を設定する方法を示します。
using System;
using System.Windows.Forms;
using System.Drawing;

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

        public BorderDemo()
        {
            this.Text = "Border Demo";
            this.Size = new Size(550, 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.panel.AutoSize = true;
            this.Controls.Add(panel);

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

            this.Load += new EventHandler(Form1_Load);

            InitButton();

            this.StartPosition = FormStartPosition.CenterScreen;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            gcMultiRow1.Template = Template.CreateGridTemplate(1, 100, 40);
            gcMultiRow1.RowCount = 5;
            gcMultiRow1.BackColor = Color.Wheat;
            // Fill values.
            for (int rowIndex = 0; rowIndex < gcMultiRow1.RowCount; rowIndex++)
            {
                gcMultiRow1[rowIndex, 0].Value = rowIndex.ToString();
            }
            // Keep the values when change MultiRow control's template1.
            gcMultiRow1.RestoreValue = true;
        }

        #region Button Event Handlers
        void setNormalBorderToCell_Click(object sender, EventArgs e)
        {
            Template template1 = gcMultiRow1.Template;

            Row row = template1.Row;

            Border normalBorder1 = new Border();

            //The outline borders has the LineStyle.Medium style and Red color.
            //normalBorder1.Outline = new Line(LineStyle.Medium, Color.Red);

            //Except the above, you can set each border in different style or color.
            normalBorder1.Top = new Line(LineStyle.SlantedDashDot, Color.Red);
            normalBorder1.Bottom = new Line(LineStyle.SlantedDashDot, Color.Orange);
            normalBorder1.Left = new Line(LineStyle.SlantedDashDot, Color.Blue);
            normalBorder1.Right = new Line(LineStyle.SlantedDashDot, Color.Green);

            row.Cells[0].Style.Border = normalBorder1;

            // Reload template1.
            this.gcMultiRow1.Template = template1;
        }

        void setRoundedBorderToCell_Click(object sender, EventArgs e)
        {
            Template template1 = gcMultiRow1.Template;
            Row row = template1.Row;

            //Using this constructor can set the outline RoundedBorder
            RoundedBorder roundedBorder1 = new RoundedBorder();
            roundedBorder1.Outline = new Line(LineStyle.MediumDashed, Color.Orange);
            roundedBorder1.AllCornerRadius = 0.3f;
            row.Cells[0].Style.Border = roundedBorder1;

            // Reload template1.
            this.gcMultiRow1.Template = template1;
        }

        void setRoundedBorderCornerRadiusToCell_Click(object sender, EventArgs e)
        {
            Template template1 = gcMultiRow1.Template;

            RoundedBorder roundedBorder1 = new RoundedBorder(LineStyle.Medium, Color.Red);
            //Only set the TopLeftCorner and TopRightCorner.
            roundedBorder1.TopLeftCornerRadius = 0.3f;
            roundedBorder1.TopRightCornerRadius = 0.3f;
            template1.Row.Cells[0].Style.Border = roundedBorder1;

            // Reload template1.
            this.gcMultiRow1.Template = template1;
        }

        RoundedBorder smoothingLineRoundedBorder = new RoundedBorder(LineStyle.Medium, Color.Blue, 0.3f);
        void setRoundedBorderUseSmoothingLine_Click(object sender, EventArgs e)
        {
            Template template1 = gcMultiRow1.Template;
            Row row = template1.Row;
            
            if (smoothingLineRoundedBorder.UseSmoothingLine == false)
            {
                //If UseSmoothingLine is true, the corner line has a good effect.
                smoothingLineRoundedBorder.UseSmoothingLine = true;
            }
            else
            {
                smoothingLineRoundedBorder.UseSmoothingLine = false;
            }
            row.Cells[0].Style.Border = smoothingLineRoundedBorder;

            // Reload template1.
            this.gcMultiRow1.Template = template1;
        }

        void setThreeDBorderToRow_Click(object sender, EventArgs e)
        {
            Template template1 = gcMultiRow1.Template;
            Row row = template1.Row;

            if (row.Border is ThreeDBorder)
            {
                row.Border = Border.Empty;
            }
            else
            {
                //Using this constructor can set the outline ThreeDBorder
                ThreeDBorder threeDBorder1 = new ThreeDBorder(Color.Gray, Color.DarkGray, Color.White, Color.LightGray);
                threeDBorder1.ThreeDEffect = ThreeDEffect.Raised;
                //Set ThreeDBorder to Row.
                row.Border = threeDBorder1;
            }

            // Reload template1.
            this.gcMultiRow1.Template = template1;
        }

        void setThreeDBorderToCell_Click(object sender, EventArgs e)
        {
            Template template1 = gcMultiRow1.Template;

            Row row = template1.Row;

            ThreeDBorder threeDBorder1 = new ThreeDBorder();
            threeDBorder1.DarkColor = Color.Gray;
            threeDBorder1.DarkDarkColor = Color.DarkGray;
            threeDBorder1.LightColor = Color.White;
            threeDBorder1.LightLightColor = Color.LightGray;

            threeDBorder1.ThreeDEffect = ThreeDEffect.Sunken;

            row.Cells[0].Style.Border = threeDBorder1;

            // Reload template1.
            this.gcMultiRow1.Template = template1;
        }

        void setCrossBorderToCell_Click(object sender, EventArgs e)
        {
            Template template1 = gcMultiRow1.Template;

            Row row = template1.Row;

            //Using this constructor can set the outline regular rectangle border.
            Border normalBorder1 = new Border(LineStyle.Medium, Color.Red);

            normalBorder1.DiagonalDown = new Line(LineStyle.Medium, Color.Red);
            normalBorder1.DiagonalUp = new Line(LineStyle.Medium, Color.Red);

            row.Cells[0].Style.Border = normalBorder1;

            // Reload template1.
            this.gcMultiRow1.Template = template1;
        }

        #endregion

        #region Initialize Buttons

        private void InitButton()
        {
            AddButton(setNormalBorderToCell, "Set Normal border to Cell", new EventHandler(setNormalBorderToCell_Click));
            AddButton(setRoundedBorderToCell, "Set Rounded border to Cell", new EventHandler(setRoundedBorderToCell_Click));
            AddButton(setRoundedBorderCornerRadiusToCell, "Set RoundedBorder Corner Radius to Cell", new EventHandler(setRoundedBorderCornerRadiusToCell_Click));
            AddButton(setRoundedBorderUseSmoothingLine, "Set RoundedBorder.UseSmoothingLine to Cell", new EventHandler(setRoundedBorderUseSmoothingLine_Click));
            AddButton(setThreeDBorderToCell, "Set ThreeDBorder to Cell", new EventHandler(setThreeDBorderToCell_Click));
            AddButton(setThreeDBorderToRow, "Set ThreeDBorder to Row", new EventHandler(setThreeDBorderToRow_Click));
            AddButton(setCrossBorderToCell, "Set CrossBorder to Cell", new EventHandler(setCrossBorderToCell_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 setNormalBorderToCell = new Button();
        Button setRoundedBorderToCell = new Button();
        Button setRoundedBorderCornerRadiusToCell = new Button();
        Button setRoundedBorderUseSmoothingLine = new Button();
        Button setThreeDBorderToRow = new Button();
        Button setThreeDBorderToCell = new Button();
        Button setCrossBorderToCell = new Button();

        #endregion

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

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

    Public Sub New()
        Me.Text = "Border Demo"
        Me.Size = New Size(550, 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.panel.AutoSize = True
        Me.Controls.Add(panel)

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

        InitButton()

        Me.StartPosition = FormStartPosition.CenterScreen
    End Sub

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        gcMultiRow1.Template = Template.CreateGridTemplate(1, 100, 40)
        gcMultiRow1.RowCount = 5
        gcMultiRow1.BackColor = Color.Wheat
        ' Fill values.
        Dim rowIndex As Integer = 0
        While rowIndex < gcMultiRow1.RowCount
            gcMultiRow1(rowIndex, 0).Value = rowIndex.ToString()
            System.Math.Max(System.Threading.Interlocked.Increment(rowIndex), rowIndex - 1)
        End While
        ' Keep the values when change MultiRow control's template1.
        gcMultiRow1.RestoreValue = True
    End Sub

#Region "Button Event Handlers"
    Private Sub setNormalBorderToCell_Click(ByVal sender As Object, ByVal e As EventArgs) Handles setNormalBorderToCell.Click
        Dim template1 As Template = gcMultiRow1.Template

        Dim row As Row = template1.Row

        Dim normalBorder1 As New Border()

        'The outline borders has the LineStyle.Medium style and Red color.
        'normalBorder1.Outline = new Line(LineStyle.Medium, Color.Red);

        'Except the above, you can set each border in different style or color.
        normalBorder1.Top = New Line(LineStyle.SlantedDashDot, Color.Red)
        normalBorder1.Bottom = New Line(LineStyle.SlantedDashDot, Color.Orange)
        normalBorder1.Left = New Line(LineStyle.SlantedDashDot, Color.Blue)
        normalBorder1.Right = New Line(LineStyle.SlantedDashDot, Color.Green)
        row.Cells(0).Style.Border = normalBorder1

        ' Reload template1.
        Me.gcMultiRow1.Template = template1
    End Sub

    Private Sub setRoundedBorderToCell_Click(ByVal sender As Object, ByVal e As EventArgs) Handles setRoundedBorderToCell.Click
        Dim template1 As Template = gcMultiRow1.Template
        Dim row As Row = template1.Row

        'Using this constructor can set the outline RoundedBorder
        Dim roundedBorder1 As New RoundedBorder()
        roundedBorder1.Outline = New Line(LineStyle.MediumDashed, Color.Orange)
        roundedBorder1.AllCornerRadius = 0.3F
        row.Cells(0).Style.Border = roundedBorder1

        ' Reload template1.
        Me.gcMultiRow1.Template = template1
    End Sub

    Private Sub setRoundedBorderCornerRadiusToCell_Click(ByVal sender As Object, ByVal e As EventArgs) Handles setRoundedBorderCornerRadiusToCell.Click
        Dim template1 As Template = gcMultiRow1.Template

        Dim roundedBorder1 As New RoundedBorder(LineStyle.Medium, Color.Red)
        'Only set the TopLeftCorner and TopRightCorner.
        roundedBorder1.TopLeftCornerRadius = 0.3F
        roundedBorder1.TopRightCornerRadius = 0.3F
        template1.Row.Cells(0).Style.Border = roundedBorder1

        ' Reload template1.
        Me.gcMultiRow1.Template = template1
    End Sub

    Private smoothingLineRoundedBorder As New RoundedBorder(LineStyle.Medium, Color.Blue, 0.3F)
    Private Sub setRoundedBorderUseSmoothingLine_Click(ByVal sender As Object, ByVal e As EventArgs) Handles setRoundedBorderUseSmoothingLine.Click
        Dim template1 As Template = gcMultiRow1.Template
        Dim row As Row = template1.Row

        If smoothingLineRoundedBorder.UseSmoothingLine = False Then
            'If UseSmoothingLine is true, the corner line has a good effect.
            smoothingLineRoundedBorder.UseSmoothingLine = True
        Else
            smoothingLineRoundedBorder.UseSmoothingLine = False
        End If
        row.Cells(0).Style.Border = smoothingLineRoundedBorder

        ' Reload template1.
        Me.gcMultiRow1.Template = template1
    End Sub

    Private Sub setThreeDBorderToRow_Click(ByVal sender As Object, ByVal e As EventArgs) Handles setThreeDBorderToRow.Click
        Dim template1 As Template = gcMultiRow1.Template
        Dim row As Row = template1.Row

        If TypeOf row.Border Is ThreeDBorder Then
            row.Border = Border.Empty
        Else
            'Using this constructor can set the outline ThreeDBorder
            Dim threeDBorder1 As New ThreeDBorder(Color.Gray, Color.DarkGray, Color.White, Color.LightGray)
            threeDBorder1.ThreeDEffect = ThreeDEffect.Raised
            'Set ThreeDBorder to Row.
            row.Border = threeDBorder1
        End If

        ' Reload template1.
        Me.gcMultiRow1.Template = template1
    End Sub

    Private Sub setThreeDBorderToCell_Click(ByVal sender As Object, ByVal e As EventArgs) Handles setThreeDBorderToCell.Click
        Dim template1 As Template = gcMultiRow1.Template

        Dim row As Row = template1.Row

        Dim threeDBorder1 As New ThreeDBorder()
        threeDBorder1.DarkColor = Color.Gray
        threeDBorder1.DarkDarkColor = Color.DarkGray
        threeDBorder1.LightColor = Color.White
        threeDBorder1.LightLightColor = Color.LightGray

        threeDBorder1.ThreeDEffect = ThreeDEffect.Sunken
        row.Cells(0).Style.Border = threeDBorder1

        ' Reload template1.
        Me.gcMultiRow1.Template = template1
    End Sub

    Private Sub setCrossBorderToCell_Click(ByVal sender As Object, ByVal e As EventArgs) Handles setCrossBorderToCell.Click
        Dim template1 As Template = gcMultiRow1.Template

        Dim row As Row = template1.Row

        'Using this constructor can set the outline regular rectangle border.
        Dim normalBorder1 As New Border(LineStyle.Medium, Color.Red)

        normalBorder1.DiagonalDown = New Line(LineStyle.Medium, Color.Red)
        normalBorder1.DiagonalUp = New Line(LineStyle.Medium, Color.Red)
        row.Cells(0).Style.Border = normalBorder1

        ' Reload template1.
        Me.gcMultiRow1.Template = template1
    End Sub

#End Region

#Region "Initialize Buttons"

    Private Sub InitButton()
        AddButton(setNormalBorderToCell, "Set Normal border to Cell")
        AddButton(setRoundedBorderToCell, "Set Rounded border to Cell")
        AddButton(setRoundedBorderCornerRadiusToCell, "Set RoundedBorder Corner Radius to Cell")
        AddButton(setRoundedBorderUseSmoothingLine, "Set RoundedBorder.UseSmoothingLine to Cell")
        AddButton(setThreeDBorderToCell, "Set ThreeDBorder to Cell")
        AddButton(setThreeDBorderToRow, "Set ThreeDBorder to Row")
        AddButton(setCrossBorderToCell, "Set CrossBorder to Cell")
    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 setNormalBorderToCell As New Button()
    Friend WithEvents setRoundedBorderToCell As New Button()
    Friend WithEvents setRoundedBorderCornerRadiusToCell As New Button()
    Friend WithEvents setRoundedBorderUseSmoothingLine As New Button()
    Friend WithEvents setThreeDBorderToRow As New Button()
    Friend WithEvents setThreeDBorderToCell As New Button()
    Friend WithEvents setCrossBorderToCell As New Button()

#End Region

    <STAThreadAttribute()> _
    Public Shared Sub Main()
        Application.EnableVisualStyles()
        Application.Run(New BorderDemo())
    End Sub
End Class
継承階層

System.Object
   GrapeCity.Win.MultiRow.BorderBase
      GrapeCity.Win.MultiRow.Border
         GrapeCity.Win.MultiRow.RoundedBorder

参照

Border メンバ
GrapeCity.Win.MultiRow 名前空間
Line 構造体
BorderBase クラス
RoundedBorder クラス
ThreeDBorder クラス

 

 


© 2008-2015 GrapeCity inc. All rights reserved.