本文整理匯總了C#中System.Windows.Forms.DataGridViewAdvancedBorderStyle類的典型用法代碼示例。如果您正苦於以下問題:C# DataGridViewAdvancedBorderStyle類的具體用法?C# DataGridViewAdvancedBorderStyle怎麽用?C# DataGridViewAdvancedBorderStyle使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DataGridViewAdvancedBorderStyle類屬於System.Windows.Forms命名空間,在下文中一共展示了DataGridViewAdvancedBorderStyle類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Main
//引入命名空間
using System;
using System.Drawing;
using System.Windows.Forms;
namespace DataGridViewAdvancedBorderStyleSample
{
class Form1 : Form
{
[STAThreadAttribute()]
public static void Main()
{
Application.EnableVisualStyles();
Application.Run(new Form1());
}
public Form1()
{
this.AutoSize = true;
this.Controls.Add(new CustomDataGridView());
this.Text = "DataGridView advanced border styles demo";
}
}
public class CustomDataGridView : DataGridView
{
public CustomDataGridView()
{
this.RowTemplate = new DataGridViewCustomRow();
this.Columns.Add(new DataGridViewCustomColumn());
this.Columns.Add(new DataGridViewCustomColumn());
this.Columns.Add(new DataGridViewCustomColumn());
this.RowCount = 4;
this.EnableHeadersVisualStyles = false;
this.AutoSize = true;
}
public override DataGridViewAdvancedBorderStyle AdjustedTopLeftHeaderBorderStyle
{
get
{
DataGridViewAdvancedBorderStyle newStyle =
new DataGridViewAdvancedBorderStyle();
newStyle.Top = DataGridViewAdvancedCellBorderStyle.None;
newStyle.Left = DataGridViewAdvancedCellBorderStyle.None;
newStyle.Bottom = DataGridViewAdvancedCellBorderStyle.Outset;
newStyle.Right = DataGridViewAdvancedCellBorderStyle.OutsetDouble;
return newStyle;
}
}
public override DataGridViewAdvancedBorderStyle AdjustColumnHeaderBorderStyle(
DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStyleInput,
DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceHolder,
bool firstDisplayedColumn,
bool lastVisibleColumn)
{
// Customize the left border of the first column header and the
// bottom border of all the column headers. Use the input style for
// all other borders.
dataGridViewAdvancedBorderStylePlaceHolder.Left = firstDisplayedColumn ?
DataGridViewAdvancedCellBorderStyle.OutsetDouble :
DataGridViewAdvancedCellBorderStyle.None;
dataGridViewAdvancedBorderStylePlaceHolder.Bottom =
DataGridViewAdvancedCellBorderStyle.Single;
dataGridViewAdvancedBorderStylePlaceHolder.Right =
dataGridViewAdvancedBorderStyleInput.Right;
dataGridViewAdvancedBorderStylePlaceHolder.Top =
dataGridViewAdvancedBorderStyleInput.Top;
return dataGridViewAdvancedBorderStylePlaceHolder;
}
}
public class DataGridViewCustomColumn : DataGridViewColumn
{
public DataGridViewCustomColumn()
{
this.CellTemplate = new DataGridViewCustomCell();
}
}
public class DataGridViewCustomCell : DataGridViewTextBoxCell
{
public override DataGridViewAdvancedBorderStyle AdjustCellBorderStyle(
DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStyleInput,
DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceHolder,
bool singleVerticalBorderAdded,
bool singleHorizontalBorderAdded,
bool firstVisibleColumn,
bool firstVisibleRow)
{
// Customize the top border of cells in the first row and the
// right border of cells in the first column. Use the input style
// for all other borders.
dataGridViewAdvancedBorderStylePlaceHolder.Left = firstVisibleColumn ?
DataGridViewAdvancedCellBorderStyle.OutsetDouble :
DataGridViewAdvancedCellBorderStyle.None;
dataGridViewAdvancedBorderStylePlaceHolder.Top = firstVisibleRow ?
DataGridViewAdvancedCellBorderStyle.InsetDouble :
DataGridViewAdvancedCellBorderStyle.None;
dataGridViewAdvancedBorderStylePlaceHolder.Right =
dataGridViewAdvancedBorderStyleInput.Right;
dataGridViewAdvancedBorderStylePlaceHolder.Bottom =
dataGridViewAdvancedBorderStyleInput.Bottom;
return dataGridViewAdvancedBorderStylePlaceHolder;
}
}
public class DataGridViewCustomRow : DataGridViewRow
{
public override DataGridViewAdvancedBorderStyle AdjustRowHeaderBorderStyle(
DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStyleInput,
DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceHolder,
bool singleVerticalBorderAdded,
bool singleHorizontalBorderAdded,
bool isFirstDisplayedRow,
bool isLastDisplayedRow)
{
// Customize the top border of the first row header and the
// right border of all the row headers. Use the input style for
// all other borders.
dataGridViewAdvancedBorderStylePlaceHolder.Top = isFirstDisplayedRow ?
DataGridViewAdvancedCellBorderStyle.InsetDouble :
DataGridViewAdvancedCellBorderStyle.None;
dataGridViewAdvancedBorderStylePlaceHolder.Right =
DataGridViewAdvancedCellBorderStyle.OutsetDouble;
dataGridViewAdvancedBorderStylePlaceHolder.Left =
dataGridViewAdvancedBorderStyleInput.Left;
dataGridViewAdvancedBorderStylePlaceHolder.Bottom =
dataGridViewAdvancedBorderStyleInput.Bottom;
return dataGridViewAdvancedBorderStylePlaceHolder;
}
}
}