本文整理汇总了C#中System.Windows.Forms.DataGridView.AutoResizeRowHeadersWidth方法的典型用法代码示例。如果您正苦于以下问题:C# DataGridView.AutoResizeRowHeadersWidth方法的具体用法?C# DataGridView.AutoResizeRowHeadersWidth怎么用?C# DataGridView.AutoResizeRowHeadersWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.DataGridView
的用法示例。
在下文中一共展示了DataGridView.AutoResizeRowHeadersWidth方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: customizationDataGridView
public static void customizationDataGridView(DataGridView dgv)
{
dgv.ClearSelection();
dgv.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToDisplayedHeaders);
for (var i = 0; i < dgv.ColumnCount; i++)
{
dgv.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
dgv.Columns[i].FillWeight = 1;
}
}
示例2: cargarDataGridViewConciliacionAutomatica
public void cargarDataGridViewConciliacionAutomatica(DataGridView dgv, IEnumerable<Object> lista, String p_modoEdicion, bool crea_encabezados)
{
try
{
Trace.TraceInformation(dgv.ToString());
Trace.TraceInformation(lista.ToString());
if (crea_encabezados)
{
//dgv.Rows.Clear();
dgv.Columns.Clear();
foreach (var item in lista)
{
Type t = item.GetType();
PropertyInfo[] pi = t.GetProperties();
foreach (PropertyInfo p in pi)
{
DataGridViewColumn columna = new DataGridViewColumn();
DataGridViewCell cell = new DataGridViewTextBoxCell();
columna.CellTemplate = cell;
columna.Name = p.Name;
columna.HeaderText = p.Name;
columna.ReadOnly = true;
columna.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
switch ( columna.Name )
{
case "NIVEL": columna.Visible = false; break;
case "IdArchivoTarjetaDetalle": columna.Visible = false; break;
}
dgv.Columns.Add(columna);
}
break;
}
DataGridViewCheckBoxColumn doWork = new DataGridViewCheckBoxColumn();
doWork.Name = "CONCILIAR";
doWork.HeaderText = "CONCILIAR";
doWork.FalseValue = "0";
doWork.TrueValue = "1";
dgv.Columns.Add(doWork);
} //crea_encabezados
var i=0;
foreach (object item in lista)
{
this.progressBar1.BringToFront();
dgv.Refresh();
//System.Threading.Thread.Sleep(10);
Application.DoEvents();
this.progressBar1.Increment(i++);
var row = dgv.Rows.Add();
dgv.Rows[row].HeaderCell.Value = i.ToString();
Type t = item.GetType();
PropertyInfo[] pi = t.GetProperties();
foreach (PropertyInfo p in pi)
{
Console.WriteLine(p.Name + " " + p.GetValue(item, null));
dgv.Rows[row].Cells[p.Name].Value = p.GetValue(item, null);
}
if (p_modoEdicion == "SI")
{
dgv.Rows[row].Cells["CONCILIAR"].Value = true;
}
switch (dgv.Rows[row].Cells["NIVEL"].Value.ToString())
{
case "-1": dgv.Rows[row].Cells["CONCILIAR"].Value = false;
dgv.Rows[row].ReadOnly = true;
dgv.Rows[row].DefaultCellStyle.BackColor = Color.White;
dgv.Rows[row].DefaultCellStyle.ForeColor = Color.Black;
break;
case "1": dgv.Rows[row].DefaultCellStyle.BackColor = Color.DarkGreen;
dgv.Rows[row].DefaultCellStyle.ForeColor = Color.White;
dgv.Rows[row].Cells["CONCILIAR"].Value = true;
break;
case "2": dgv.Rows[row].DefaultCellStyle.BackColor = Color.LightBlue; break;
case "3": dgv.Rows[row].DefaultCellStyle.BackColor = Color.Orange; break;
case "4": dgv.Rows[row].DefaultCellStyle.BackColor = Color.OrangeRed; break;
default:
dgv.Rows[row].Cells["CONCILIAR"].Value = false;
dgv.Rows[row].ReadOnly = true;
dgv.Rows[row].DefaultCellStyle.BackColor = Color.White;
dgv.Rows[row].DefaultCellStyle.ForeColor = Color.Black;
break;
}
dgv.Rows[row].Cells["FECHA_PAGO"].Value = dgv.Rows[row].Cells["FECHA_PAGO"].Value .ToString().Remove(10);
}
dgv.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders);
//.........这里部分代码省略.........
示例3: EnumerateLines
public virtual void EnumerateLines(DataGridView dgv)
{
for (int i = 0; i < dgv.Rows.Count; i++)
{
dgv.Rows[i].HeaderCell.Value = i.ToString();
}
// ----
dgv.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders);
}
示例4: SetDataGridViewRowNumbers
public static void SetDataGridViewRowNumbers(DataGridView dataGridView)
{
foreach (DataGridViewRow row in dataGridView.Rows)
{
if (!row.IsNewRow)
{
row.HeaderCell.Value = string.Format("{0}", row.Index + 1);
}
}
dataGridView.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders);
}
示例5: setRowNumber
public void setRowNumber(DataGridView dgv)
{
foreach (DataGridViewRow row in dgv.Rows)
{
row.HeaderCell.Value = row.Index + 1;
}
dgv.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders);
}