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


C# Forms.DataGridViewCell類代碼示例

本文整理匯總了C#中System.Windows.Forms.DataGridViewCell的典型用法代碼示例。如果您正苦於以下問題:C# DataGridViewCell類的具體用法?C# DataGridViewCell怎麽用?C# DataGridViewCell使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DataGridViewCell類屬於System.Windows.Forms命名空間,在下文中一共展示了DataGridViewCell類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


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