当前位置: 首页>>代码示例>>C#>>正文


C# DataGridView.AutoResizeRowHeadersWidth方法代码示例

本文整理汇总了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;
            }
        }
开发者ID:acherkashin,项目名称:TentMap,代码行数:11,代码来源:HelperDataGridView.cs

示例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);
//.........这里部分代码省略.........
开发者ID:quidele,项目名称:tezecoop,代码行数:101,代码来源:FrmConciliaciones.cs

示例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);
 }
开发者ID:stimpy76,项目名称:OpenMuS9,代码行数:9,代码来源:BmdFile.cs

示例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);
 }
开发者ID:joaonc,项目名称:jdn2common,代码行数:11,代码来源:DataUtil.cs

示例5: setRowNumber

        public void setRowNumber(DataGridView dgv)
        {
            foreach (DataGridViewRow row in dgv.Rows)
            {
                row.HeaderCell.Value = row.Index + 1;
            }

            dgv.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders);
        }
开发者ID:seanclogher,项目名称:Modelling-Tool,代码行数:9,代码来源:DataCleanUp.cs


注:本文中的System.Windows.Forms.DataGridView.AutoResizeRowHeadersWidth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。