本文整理汇总了C#中System.Windows.Forms.DataGridViewColumn类的典型用法代码示例。如果您正苦于以下问题:C# DataGridViewColumn类的具体用法?C# DataGridViewColumn怎么用?C# DataGridViewColumn使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataGridViewColumn类属于System.Windows.Forms命名空间,在下文中一共展示了DataGridViewColumn类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateEmptyGrid
void CreateEmptyGrid()
{
m_Grid = new DataGridView();
m_Grid.ReadOnly = true;
m_Grid.Parent = this;
m_Grid.Dock = DockStyle.Fill;
m_Table = new DataTable();
m_Grid.DataSource = m_Table;
//Add base item attributes
Type ItemType = typeof(GameplayItem);
Type ItemAttrType = typeof(ItemAttributes);
System.Reflection.FieldInfo[] ItemFields = ItemType.GetFields();
System.Reflection.FieldInfo[] ItemAttrFields = ItemAttrType.GetFields();
List<string> FieldNames = new List<string>();
foreach (System.Reflection.FieldInfo Info in ItemFields)
{
FieldNames.Add(Info.Name);
DataGridViewColumn Col = new DataGridViewColumn(CreateCellTemplate(Info));
Col.Name = Info.Name;
//m_Grid.Columns.Add(Col);
m_Table.Columns.Add(Info.Name, Info.FieldType);
}
foreach (System.Reflection.FieldInfo Info in ItemAttrFields)
{
FieldNames.Add(Info.Name);
DataGridViewColumn Col = new DataGridViewColumn(CreateCellTemplate(Info));
Col.Name = Info.Name;
//m_Grid.Columns.Add(Col);
m_Table.Columns.Add(Info.Name, Info.FieldType);
}
}
示例2: _btnSelect_Click
private void _btnSelect_Click(object sender, EventArgs e)
{
foreach (string cl in _clbShowColumn.CheckedItems)
{
DataGridViewColumn _column = new DataGridViewColumn();
_column.CellTemplate = new DataGridViewTextBoxCell();
_column.Name = cl;
_column.HeaderText = cl;
_column.DataPropertyName = cl;
_column.SortMode = DataGridViewColumnSortMode.Automatic;
switch(_InsertionType)
{
case InsertionType.Before :
_Grid.Columns.Insert(_ColumnPosition, _column);
break;
case InsertionType.After :
_Grid.Columns.Insert(_ColumnPosition + 1, _column);
break;
}
}
this.Close();
}
示例3: GetColumnText
string GetColumnText(DataGridViewColumn column)
{
if (column.HeaderText == "" && column is DataGridViewButtonColumn)
return ((DataGridViewButtonColumn)column).Text;
return column.HeaderText;
}
示例4: GetColunas
public override DataGridViewColumn[] GetColunas()
{
var colunas = new DataGridViewColumn[]
{
new DataGridViewTextBoxColumn
{
DataPropertyName = "Id",
HeaderText = "Id",
},
new DataGridViewTextBoxColumn
{
DataPropertyName = "Descricao",
HeaderText = "Descricao"
},
new DataGridViewTextBoxColumn
{
DataPropertyName = "Valor",
HeaderText = "Valor"
},
new DataGridViewTextBoxColumn
{
DataPropertyName = "Categoria",
HeaderText = "Categoria"
},
new DataGridViewTextBoxColumn
{
DataPropertyName = "Cliente",
HeaderText = "Cliente"
}
};
return colunas;
}
示例5: data_grid
public static void data_grid(DataGridView dgv_grid)
{
dgv_grid.AutoGenerateColumns = true;
DataGridViewCell Cell_1 = new DataGridViewTextBoxCell();
DataGridViewCell Cell_2 = new DataGridViewTextBoxCell();
DataGridViewCell Cell_3 = new DataGridViewTextBoxCell();
DataGridViewColumn col__from = new DataGridViewColumn();
DataGridViewColumn col__to = new DataGridViewColumn();
DataGridViewColumn col__length = new DataGridViewColumn();
col__from.HeaderText = "Откуда";
col__to.HeaderText = "Куда";
col__length.HeaderText = "Длина";
col__from.Width = 110;
col__to.Width = 110;
col__length.Width = 110;
col__from.CellTemplate = Cell_1;
col__to.CellTemplate = Cell_2;
col__length.CellTemplate = Cell_3;
dgv_grid.ReadOnly = false;
dgv_grid.AllowUserToAddRows = true;
dgv_grid.AllowUserToDeleteRows = true;
dgv_grid.Columns.Add(col__from);
dgv_grid.Columns.Add(col__to);
dgv_grid.Columns.Add(col__length);
}
示例6: DataGridViewColumnSpec
public DataGridViewColumnSpec(DataGridViewColumn column, Color backColor, Image image, bool useImage) : this(column, image)
{
Column = column;
this.Image = image;
BackColor = backColor;
UseImage = useImage;
}
示例7: AFN
public AFN(ArrayList transicio,string[] estadosA,string []sim, string [] esta, string ini)
{
InitializeComponent();
transiciones = transicio;
estadosAceptacion=estadosA;
simbolos=sim;
estados=esta;
inicio=ini;
for(int a=0;a<simbolos.Length;a++)
{
DataGridViewColumn columna = new DataGridViewColumn(new DataGridViewTextBoxCell());
columna.Name = (string)simbolos[a];
columna.Width = 30;
dataGridView1.Columns.Add(columna);
}
DataGridViewColumn columnaf = new DataGridViewColumn(new DataGridViewTextBoxCell());
columnaf.Name = "F";
dataGridView1.Columns.Add(columnaf);
for (int b = 0; b < estados.Length; b++)
{
dataGridView1.Rows.Add();
dataGridView1["QΣ", b].Value = estados[b];
}
agregarDatos();
}
示例8: TableForm
public TableForm(string name, IDataReader rdr)
{
DataGridView dgv = new DataGridView();
dgv.Dock = DockStyle.Fill;
DataGridViewTextBoxCell template = new DataGridViewTextBoxCell();
template.Style.Font = new Font("DejaVu Sans",10);
for (int i = 0;i < rdr.FieldCount;i++)
{
DataGridViewColumn col = new DataGridViewColumn(template);
col.Name = rdr.GetName(i);
dgv.Columns.Add(col);
}
while (rdr.Read())
{
DataGridViewRow row = new DataGridViewRow();
row.CreateCells(dgv);
for (int i = 0;i < rdr.FieldCount;i++)
{
object val = rdr[i];
if (val is byte[])
{
val = Encoding.UTF8.GetString((byte[])val);
}
row.Cells[i].Value = val;
}
dgv.Rows.Add(row);
}
Controls.Add(dgv);
}
示例9: SetColumnToDateFormat
public void SetColumnToDateFormat(DataGridViewColumn column, string format)
{
column.DefaultCellStyle = new DataGridViewCellStyle
{
Format = format
};
}
示例10: CheckBoxColumnHeaderHandler
/// ------------------------------------------------------------------------------------
/// <summary>
/// Constructor.
/// </summary>
/// ------------------------------------------------------------------------------------
public CheckBoxColumnHeaderHandler(DataGridViewColumn col)
{
Debug.Assert(col != null);
Debug.Assert(col is DataGridViewCheckBoxColumn);
Debug.Assert(col.DataGridView != null);
m_col = col;
m_grid = col.DataGridView;
m_grid.HandleDestroyed += HandleHandleDestroyed;
m_grid.CellPainting += HandleHeaderCellPainting;
m_grid.CellMouseMove += HandleHeaderCellMouseMove;
m_grid.ColumnHeaderMouseClick += HandleHeaderCellMouseClick;
m_grid.CellContentClick += HandleDataCellCellContentClick;
m_grid.Scroll += HandleGridScroll;
m_grid.RowsAdded += HandleGridRowsAdded;
m_grid.RowsRemoved += HandleGridRowsRemoved;
if (!Application.RenderWithVisualStyles)
{
m_szCheckBox = new Size(13, 13);
}
else
{
var element = VisualStyleElement.Button.CheckBox.CheckedNormal;
var renderer = new VisualStyleRenderer(element);
using (var g = m_grid.CreateGraphics())
m_szCheckBox = renderer.GetPartSize(g, ThemeSizeType.True);
}
m_stringFormat = new StringFormat(StringFormat.GenericTypographic);
m_stringFormat.Alignment = StringAlignment.Center;
m_stringFormat.LineAlignment = StringAlignment.Center;
m_stringFormat.Trimming = StringTrimming.EllipsisCharacter;
m_stringFormat.FormatFlags |= StringFormatFlags.NoWrap;
}
示例11: InitialDataGridView
public void InitialDataGridView()
{
dataGridView.Rows.Clear();
dataGridView.Columns.Clear();
DataGridViewCell textCell = new DataGridViewTextBoxCell();
DataGridViewColumn timeColumn = new DataGridViewColumn();
timeColumn.HeaderText = "记录时间";
timeColumn.Width = 160;
timeColumn.CellTemplate = textCell;
DataGridViewColumn ipColumn = new DataGridViewColumn();
ipColumn.HeaderText = "IP地址";
ipColumn.Width = 120;
ipColumn.CellTemplate = textCell;
DataGridViewColumn portColumn = new DataGridViewColumn();
portColumn.HeaderText = "端口号";
portColumn.Width = 80;
portColumn.CellTemplate = textCell;
DataGridViewColumn statusColumn = new DataGridViewColumn();
statusColumn.HeaderText = "工作状态";
statusColumn.Width = 180;
statusColumn.CellTemplate = textCell;
dataGridView.Columns.Add(timeColumn);
dataGridView.Columns.Add(ipColumn);
dataGridView.Columns.Add(portColumn);
dataGridView.Columns.Add(statusColumn);
}
示例12: AddTimestampColumns
private void AddTimestampColumns()
{
DataGridViewCell cell = new DataGridViewTextBoxCell();
DataGridViewColumn column = new DataGridViewColumn();
column.HeaderText = "Total Hours";
column.Name = "TotalHours";
column.CellTemplate = cell;
column.ReadOnly = true;
this.gridTimestamps.Columns.Add( column );
cell = new DataGridViewTextBoxCell();
column = new DataGridViewColumn();
column.HeaderText = "Hourly Rate";
column.Name = "HourlyRate";
column.CellTemplate = cell;
column.ReadOnly = true;
this.gridTimestamps.Columns.Add( column );
cell = new DataGridViewTextBoxCell();
column = new DataGridViewColumn();
column.HeaderText = "Amount";
column.Name = "Amount";
column.CellTemplate = cell;
column.ReadOnly = true;
this.gridTimestamps.Columns.Add( column );
}
示例13: GetColunas
public override DataGridViewColumn[] GetColunas()
{
var colunas = new DataGridViewColumn[]
{
new DataGridViewTextBoxColumn
{
DataPropertyName = "Id",
HeaderText = "Id",
},
new DataGridViewTextBoxColumn
{
DataPropertyName = "Descricao",
HeaderText = "Descricao da Despesa",
},
new DataGridViewTextBoxColumn
{
DataPropertyName = "Valor",
HeaderText = "Valor da Despesa",
},
new DataGridViewTextBoxColumn
{
DataPropertyName = "Categoria",
HeaderText = "Categoria da Despesa",
},
new DataGridViewTextBoxColumn
{
DataPropertyName = "Fornecedor",
HeaderText = "Fornecedor",
}
};
return colunas;
}
示例14: DataGridViewSortCompareEventArgs
public DataGridViewSortCompareEventArgs (DataGridViewColumn dataGridViewColumn, object cellValue1, object cellValue2, int rowIndex1, int rowIndex2) {
this.dataGridViewColumn = dataGridViewColumn;
this.cellValue1 = cellValue1;
this.cellValue2 = cellValue2;
this.rowIndex1 = rowIndex1;
this.rowIndex2 = rowIndex2;
}
示例15: GetColumnsSortedByDisplayIndex
public static IList<DataGridViewColumn> GetColumnsSortedByDisplayIndex(DataGridView dataGridView)
{
var result = new DataGridViewColumn[dataGridView.Columns.Count];
dataGridView.Columns.CopyTo(result, 0);
Array.Sort(result, (a, b) => a.DisplayIndex.CompareTo(b.DisplayIndex));
return result;
}