本文整理汇总了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;
}
}
}
开发者ID:.NET开发者,项目名称:System.Windows.Forms,代码行数:140,代码来源:DataGridViewAdvancedBorderStyle
注:本文中的System.Windows.Forms.DataGridViewAdvancedBorderStyle类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论