當前位置: 首頁>>代碼示例>>C#>>正文


C# Forms.DataGridViewColumn類代碼示例

本文整理匯總了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);
            }
        }
開發者ID:przemyslaw-szymanski,項目名稱:dungeonworld,代碼行數:35,代碼來源:CItemGrid.cs

示例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();
        }
開發者ID:masalinas,項目名稱:konekti.net,代碼行數:25,代碼來源:ColumnFilterForm.cs

示例3: GetColumnText

        string GetColumnText(DataGridViewColumn column)
        {
            if (column.HeaderText == "" && column is DataGridViewButtonColumn)
                return ((DataGridViewButtonColumn)column).Text;

            return column.HeaderText;
        }
開發者ID:atan888,項目名稱:MMS,代碼行數:7,代碼來源:ExtendedDataGridView.ContextMenu.cs

示例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;
        }
開發者ID:FilipeAndrade,項目名稱:ePomar,代碼行數:33,代碼來源:ReceitaControl.cs

示例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);
        }
開發者ID:Zarettiii,項目名稱:ant_algorithm,代碼行數:31,代碼來源:c__data_grids.cs

示例6: DataGridViewColumnSpec

 public DataGridViewColumnSpec(DataGridViewColumn column, Color backColor, Image image, bool useImage) : this(column, image)
 {
     Column = column;
     this.Image = image;
     BackColor = backColor;
     UseImage = useImage;
 }
開發者ID:ChineduOpara,項目名稱:KCS.Common.Windows,代碼行數:7,代碼來源:DataGridViewColumnEx.cs

示例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();
        }
開發者ID:urcuqui,項目名稱:AFN-a-AFD,代碼行數:30,代碼來源:AFN.cs

示例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);
        }
開發者ID:Upliner,項目名稱:XFormTrans,代碼行數:30,代碼來源:TableForm.cs

示例9: SetColumnToDateFormat

 public void SetColumnToDateFormat(DataGridViewColumn column, string format)
 {
     column.DefaultCellStyle = new DataGridViewCellStyle
     {
         Format = format
     };
 }
開發者ID:evelasco85,項目名稱:TimeTracker,代碼行數:7,代碼來源:DataGridHelper.cs

示例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;
		}
開發者ID:bbriggs,項目名稱:FieldWorks,代碼行數:40,代碼來源:CheckBoxColumnHeaderHandler.cs

示例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);
        }
開發者ID:southpolaris,項目名稱:EMDRepository,代碼行數:27,代碼來源:ConnectionForm.cs

示例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 );
        }
開發者ID:mtrainham,項目名稱:mjt-PoolTime,代碼行數:32,代碼來源:ViewPlayerForm.cs

示例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;
        }
開發者ID:FilipeAndrade,項目名稱:ePomar,代碼行數:33,代碼來源:DespesaControl.cs

示例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;
		}
開發者ID:calumjiao,項目名稱:Mono-Class-Libraries,代碼行數:7,代碼來源:DataGridViewSortCompareEventArgs.cs

示例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;
 }
開發者ID:lgatto,項目名稱:proteowizard,代碼行數:7,代碼來源:GridUtil.cs


注:本文中的System.Windows.Forms.DataGridViewColumn類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。