• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Forms.DataGridViewCell类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Windows.Forms.DataGridViewCell的典型用法代码示例。如果您正苦于以下问题:C# DataGridViewCell类的具体用法?C# DataGridViewCell怎么用?C# DataGridViewCell使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DataGridViewCell类属于System.Windows.Forms命名空间,在下文中一共展示了DataGridViewCell类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: getValueFromCell

        public object getValueFromCell(DataGridViewCell cell)
        {
            object value = null;

            switch (cell.ValueType.Name)
                //need to do this because row.Cells["Value"].ValueType returns a string value for all cells
            {
                case "Boolean":
                    value = bool.Parse(cell.EditedFormattedValue.ToString());
                    break;
                case "Byte":
                    value = byte.Parse(cell.EditedFormattedValue.ToString());
                    break;
                case "List`1":
                    value = new List<String>(new[] { cell.EditedFormattedValue.ToString() });
                    break;
                case "UInt32":
                    value = UInt32.Parse(cell.EditedFormattedValue.ToString());
                    break;
                case "String":
                    value = cell.EditedFormattedValue.ToString();
                    break;
                case "TraceType":
                    value = Enum.Parse(typeof(TraceType), cell.Value.ToString());
                    break;
                default:
                    break;
            }
            return value;
        }
开发者ID:njmube,项目名称:FluentSharp,代码行数:30,代码来源:ascx_FindingEditor.Controllers.cs


示例2: Show

		/// ------------------------------------------------------------------------------------
		public void Show(DataGridViewCell cell, IEnumerable<string> items)
		{
			// This is sort of a kludge, but right before the first time the list is
			// displayed, it's handle hasn't been created therefore the preferred
			// size cannot be accurately determined and the preferred width is needed
			// below. So to ensure the handle gets created, show then hide the drop-down.
			if (!IsHandleCreated)
			{
				Size = new Size(0, 0);
				_dropDown.Show(0, 0);
				_dropDown.Close();
			}

			Items.Clear();
			Items.AddRange(items.ToArray());
			SelectedItem = cell.Value as string;

			if (SelectedIndex < 0 && Items.Count > 0)
				SelectedIndex = 0;

			_associatedCell = cell;
			int col = cell.ColumnIndex;
			int row = cell.RowIndex;
			Width = Math.Max(cell.DataGridView.Columns[col].Width, _listBox.PreferredSize.Width);
			Height = (Math.Min(Items.Count, 15) * _listBox.ItemHeight) + Padding.Vertical + 2;
			var rc = cell.DataGridView.GetCellDisplayRectangle(col, row, false);
			rc.Y += rc.Height;
			_dropDown.Show(cell.DataGridView.PointToScreen(rc.Location));
			_listBox.Focus();
		}
开发者ID:jwickberg,项目名称:libpalaso,代码行数:31,代码来源:CellCustomDropDownList.cs


示例3: disableCell

 public static void disableCell(DataGridViewCell cell)
 {
     cell.ReadOnly = true;
     cell.Style.ForeColor = Color.DarkGray;
     cell.Style.BackColor = Color.LightGray;
     cell.Style.SelectionBackColor = Color.LightBlue;
 }
开发者ID:hessamb,项目名称:Divan,代码行数:7,代码来源:UIHelper.cs


示例4: PerformOnCells

        /// <summary>
        /// Perform a function on grid cells.
        /// </summary>
        /// <param name="startCell">Cell from which to start. Does not wrap to start.</param>
        /// <param name="processStartCell">Whether to apply <see cref="function"/> to <see cref="startCell"/></param>
        /// <param name="stopOnFirstAction">Whether to halt processing the first time <see cref="function"/> returns true</param>
        /// <param name="function">Function to perform on the cell. Processing stops when this function returns true.</param>
        /// <returns>Whether the function ever returned true.</returns>
        public bool PerformOnCells(DataGridViewCell startCell, bool processStartCell, bool stopOnFirstAction, Func<DataGridViewCell, bool> function)
        {
            if (_grid == null || _grid.RowCount == 0 || _grid.ColumnCount == 0)
                return false;

            bool performed = false;

            int initialRow = startCell == null ? 0 : startCell.RowIndex;
            int initialCol = startCell == null ? 0 : startCell.ColumnIndex;

            int startRow = initialCol == 0 ? initialRow : initialRow + 1;

            for (int rowIndex = startRow; rowIndex < _grid.Rows.Count; rowIndex++)
            {
                DataGridViewRow row = _grid.Rows[rowIndex];

                int startCol = (rowIndex == initialRow && !processStartCell && _grid.ColumnCount > 1) ? 1 : 0;
                for (int colIndex = startCol; colIndex < row.Cells.Count; colIndex++)
                {
                    DataGridViewCell cell = row.Cells[colIndex];
                    performed |= function(cell);

                    if (performed && stopOnFirstAction)
                        return true;
                }
            }

            return performed;
        }
开发者ID:Eric4Zhang,项目名称:TFSTestStepsEditor,代码行数:37,代码来源:DataGridViewSearcher.cs


示例5: Remove

 public bool Remove(DataGridViewCell dataGridViewCell)
 {
     DataGridViewCellLinkedListElement element = null;
     DataGridViewCellLinkedListElement headElement = this.headElement;
     while (headElement != null)
     {
         if (headElement.DataGridViewCell == dataGridViewCell)
         {
             break;
         }
         element = headElement;
         headElement = headElement.Next;
     }
     if (headElement.DataGridViewCell != dataGridViewCell)
     {
         return false;
     }
     DataGridViewCellLinkedListElement next = headElement.Next;
     if (element == null)
     {
         this.headElement = next;
     }
     else
     {
         element.Next = next;
     }
     this.count--;
     this.lastAccessedElement = null;
     this.lastAccessedIndex = -1;
     return true;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:31,代码来源:DataGridViewCellLinkedList.cs


示例6: CellInfo

        public CellInfo(DataGridViewCell cell, DateTime monday)
        {
            int day = cell.ColumnIndex - 1;

            this.name = (cell.Value != null ? cell.Value.ToString() : "");
            this.tag = (cell.Tag != null ? cell.Tag.ToString() : "");
            this.toolTip = cell.ToolTipText;
            this.date = monday.AddDays(day);
            this.classTime = cell.RowIndex;

            // Get Homework

            string selectedDay = this.date.ToString("d.MM.yy");

            foreach (HomeWork hw in Data.homework)
            {
                if (hw.date.ToString("d.MM.yy") == selectedDay)
                {
                    if (hw.time == this.classTime)
                    {
                        this.homework.Add(hw);
                    }
                }
            }
        }
开发者ID:Jenjen1324,项目名称:SchuelerOffice,代码行数:25,代码来源:TimeTable.cs


示例7: GetForeColor

 private static Color GetForeColor(DataGridViewCell cell)
 {
     if (cell.Style.ForeColor != Color.Empty)
         return cell.Style.ForeColor;
     else
         return cell.OwningRow.DataGridView.DefaultCellStyle.ForeColor;
 }
开发者ID:ChrisMissal,项目名称:MyStreams,代码行数:7,代码来源:Main.cs


示例8: Add

        public virtual int Add(DataGridViewCell e)
        {
            var x = (__DataGridViewCell)(object)e;

            InternalItems.Add(x);

            return InternalItems.Count - 1;
        }
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:8,代码来源:DataGridViewCellCollection.cs


示例9: ShowErrorMsgForCell

 private void ShowErrorMsgForCell(DataGridViewCell cell)
 {
     ShowErrorMsg(cell.ErrorText);
     _grid.Select();
     foreach (DataGridViewCell c in _grid.SelectedCells)
         c.Selected = false;
     cell.Selected = true;
 }
开发者ID:vestild,项目名称:nemerle,代码行数:8,代码来源:AddNewItemWizard_Macro_Form.cs


示例10: SetCellColor

        private void SetCellColor(DataGridViewCell cell, Color fore, Color back)
        {
            cell.Style.BackColor = back;
            cell.Style.SelectionBackColor = back;

            cell.Style.ForeColor = fore;
            cell.Style.SelectionForeColor = fore;
        }
开发者ID:jpazarzis,项目名称:hogar,代码行数:8,代码来源:FiguresSummaryForm.cs


示例11: DataGridViewCellStateChangedEventArgs

 /// <include file='doc\DataGridViewCellStateChangedEventArgs.uex' path='docs/doc[@for="DataGridViewCellStateChangedEventArgs.DataGridViewCellStateChangedEventArgs"]/*' />
 public DataGridViewCellStateChangedEventArgs(DataGridViewCell dataGridViewCell, DataGridViewElementStates stateChanged)
 {
     if (dataGridViewCell == null)
     {
         throw new ArgumentNullException("dataGridViewCell");
     }
     this.dataGridViewCell = dataGridViewCell;
     this.stateChanged = stateChanged;
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:10,代码来源:DataGridViewCellStateChangedEventArgs.cs


示例12: add_grid_column

 public void add_grid_column(string name, string header, DataGridViewCell cell_template, DataGridView dgrdview)
 {
     DataGridViewColumn dgrdview_col = new DataGridViewColumn();
     dgrdview_col.Width = column_width;
     dgrdview_col.Name = name;
     dgrdview_col.HeaderText = header;
     dgrdview_col.CellTemplate = cell_template;
     dgrdview.Columns.Add(dgrdview_col);
 }
开发者ID:thecortex,项目名称:CS-Tasks,代码行数:9,代码来源:DataGridView_Helpers.cs


示例13: Display

 public void Display(ref DataGridViewCell cell)
 {
     Opened = true;
     listBox1.DataSource = new BindingSource(Helper._elReader.Items, null);
     listBox1.DisplayMember = "Key";
     listBox1.SelectedValueChanged += listBox1_SelectedValueChanged;
     _cell = cell;
     this.Show();
 }
开发者ID:Lamael,项目名称:tools,代码行数:9,代码来源:ItemSelector.cs


示例14: ReceiptFilterInfoForm

 public ReceiptFilterInfoForm(DataGridViewCell cell, DataTable dt, string fieldName, string SStorehouseId, int matType)
 {
     InitializeComponent();
     this.dt = dt;
     this.cell = cell;
     this.fieldName = fieldName;
     this.SStorehouseId = SStorehouseId;
     this.matType = matType;
 }
开发者ID:TGHGH,项目名称:Warehouse-2,代码行数:9,代码来源:ReceiptFilterInfoForm.cs


示例15: getCellValue

 public static string getCellValue(DataGridViewCell cell, bool text = false)
 {
     string str = "";
     str += cell.Value;
     if (text)
     {
         str = "'" + str + "'";
     }
     return str;
 }
开发者ID:micmax93,项目名称:AL_KAIDA_TRAVELS,代码行数:10,代码来源:Fields.cs


示例16: checkNullcell

 public static int checkNullcell(DataGridViewCell cell)
 {
     if (cell.Value.ToString() == "")
     {
         MessageBox.Show("กรุณาระบุข้อมูลให้ครบถ้วน");
         cell.Selected = true;
         return 0;
     }
     return 1;
 }
开发者ID:itktc,项目名称:projectktc-v2,代码行数:10,代码来源:Function.cs


示例17: SetCellColor

 private void SetCellColor(DataGridViewCell cell)
 {
     if (cell.Style.BackColor == Color.Red)
     {
         cell.Style.BackColor = Color.Blue;
     }
     else
     {
         cell.Style.BackColor = Color.Red;
     }
 }
开发者ID:xiaobeixin50,项目名称:test,代码行数:11,代码来源:YuceDataAnalysisForm.cs


示例18: destDoubleClick

 private void destDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     if (source == null) { return; }
     if (e.ColumnIndex < 1)
     {
         content = Field.getCellValue(destGrid.Rows[e.RowIndex].Cells[e.ColumnIndex]);
         source.Value = content;
         cTab.SelectedIndex = srcTab;
         source = null;
     }
 }
开发者ID:micmax93,项目名称:AL_KAIDA_TRAVELS,代码行数:11,代码来源:TableJump.cs


示例19: checkNullcellMt

 public static int checkNullcellMt(Form frm,DataGridViewCell cell)
 {
     if (cell.Value.ToString() == "")
     {
         cell.DataGridView.ClearSelection();
         MetroFramework.MetroMessageBox.Show(frm, "กรุณาระบุข้อมูลให้ครบถ้วน", "ผิดพลาด", MessageBoxButtons.OK, MessageBoxIcon.Question);
         cell.Selected = true;
         return 0;
     }
     return 1;
 }
开发者ID:itktc,项目名称:projectktc-v2,代码行数:11,代码来源:Function.cs


示例20: GetFont

        private static Font GetFont(DataGridViewCell cell, FontStyle fontStyle = FontStyle.Regular)
        {
            Font font;

            if (cell.Style.Font != null)
                font = cell.Style.Font;
            else
                font = cell.OwningRow.DataGridView.Font;

            return new Font(font, fontStyle);
        }
开发者ID:ChrisMissal,项目名称:MyStreams,代码行数:11,代码来源:Main.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Forms.DataGridViewCellCancelEventArgs类代码示例发布时间:2022-05-26
下一篇:
C# Forms.DataGridViewButtonColumn类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap