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


C# DataGridView.PointToClient方法代码示例

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


在下文中一共展示了DataGridView.PointToClient方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: setVisibility

        public DialogResult setVisibility(DataGridView EditedDataGridView)
        {
            try
            {

                System.Drawing.Rectangle CellRectangle1 = EditedDataGridView.GetCellDisplayRectangle(2, 2, true);

                this.Location = EditedDataGridView.PointToClient(new Point(EditedDataGridView.Left +  2 * EditedDataGridView.RowHeadersWidth, EditedDataGridView.Top + 2 * EditedDataGridView.ColumnHeadersHeight));

                foreach (DataGridViewColumn CurrentColumn in EditedDataGridView.Columns)
                {
                    dgvColumns.Rows.Add(CurrentColumn.Name,
                                        CurrentColumn.HeaderText,
                                        CurrentColumn.DisplayIndex.ToString(),
                                        CurrentColumn.Visible,
                                        CurrentColumn.AutoSizeMode.ToString(),
                                        CurrentColumn.Width.ToString(),
                                        CurrentColumn.FillWeight.ToString(),
                                        CurrentColumn.MinimumWidth.ToString());
                }

                this.ShowDialog(EditedDataGridView);

                if(this.DialogResult == System.Windows.Forms.DialogResult.OK)
                {
                    Int32 ColumnIndex=0;

                    foreach (DataGridViewColumn CurrentColumn in EditedDataGridView.Columns)
                    {
                        CurrentColumn.DisplayIndex   = Int32.Parse(dgvColumns.Rows[ColumnIndex].Cells["colDisplayIndex"].Value.ToString());
                        CurrentColumn.Visible        = (Boolean)dgvColumns.Rows[ColumnIndex].Cells["colVisible"].Value;
                        CurrentColumn.AutoSizeMode   = (DataGridViewAutoSizeColumnMode)Enum.Parse(typeof(DataGridViewAutoSizeColumnMode), (String)dgvColumns.Rows[ColumnIndex].Cells["colAutoSizeMode"].Value);

                        if(CurrentColumn.AutoSizeMode == DataGridViewAutoSizeColumnMode.Fill)
                            CurrentColumn.FillWeight     = Single.Parse(dgvColumns.Rows[ColumnIndex].Cells["colFillWeight"].Value.ToString().Replace(",", "."),System.Globalization.NumberStyles.AllowDecimalPoint,System.Globalization.CultureInfo.InvariantCulture.NumberFormat);
                        else
                            CurrentColumn.Width          = Int32.Parse(dgvColumns.Rows[ColumnIndex].Cells["colWidth"].Value.ToString());

                        CurrentColumn.MinimumWidth   = Int32.Parse(dgvColumns.Rows[ColumnIndex].Cells["colMinimumWidth"].Value.ToString());

                        ColumnIndex++;

                    }
                }

                return DialogResult;
            }
            catch (Exception ex)
            {
                throw new Exception("Error while editing column visibility", ex);
            }
        }
开发者ID:carriercomm,项目名称:ED-IBE,代码行数:52,代码来源:DataGridViewSettings.cs

示例2: DataGridViewSelection

 public DataGridViewSelection(DataGridView grid)
 {
   _rows = grid.SelectedRows.OfType<DataGridViewRow>();
   if (!_rows.Any())
   {
     _rows = grid.SelectedCells.OfType<DataGridViewCell>().Select(c => c.OwningRow).Distinct();
     var cols = grid.SelectedCells.OfType<DataGridViewCell>().Select(c => c.OwningColumn).Distinct().ToArray();
     if (cols.Length == 1)
       _columnPropertyName = cols[0].DataPropertyName;
   }
   if (!_rows.Any() && grid.CurrentCell != null)
   {
     _rows = Enumerable.Repeat(grid.CurrentCell.OwningRow, 1);
     _columnPropertyName = grid.CurrentCell.OwningColumn.DataPropertyName;
   }
   else
   {
     _rows = Enumerable.Empty<DataGridViewRow>();
     _columnPropertyName = null;
   }
   var client = grid.PointToClient(Cursor.Position);
   var hit = grid.HitTest(client.X, client.Y);
   if (!_rows.Any(r => r.Index == hit.RowIndex))
   {
     if (hit.RowIndex >= 0)
     {
       _rows = Enumerable.Repeat(grid.Rows[hit.RowIndex], 1);
       _columnPropertyName = grid.Columns[hit.ColumnIndex].DataPropertyName;
     }
     else
     {
       _rows = Enumerable.Empty<DataGridViewRow>();
       _columnPropertyName = null;
     }
   }
 }
开发者ID:rneuber1,项目名称:InnovatorAdmin,代码行数:36,代码来源:DataGridViewSelection.cs

示例3: DecideDropDestinationRowIndex

        /// <summary>
        /// ドロップ先の行の決定
        /// </summary>
        /// <param name="grid"></param>
        /// <param name="e"></param>
        /// <param name="from"></param>
        /// <param name="to"></param>
        /// <param name="next"></param>
        /// <returns></returns>
        private bool DecideDropDestinationRowIndex(
            DataGridView grid, DragEventArgs e,
            out int from, out int to, out bool next)
        {
            from = (int)e.Data.GetData(typeof(int));
            // 元の行が追加用の行であれば、常に false
            if (grid.NewRowIndex != -1 && grid.NewRowIndex == from)
            {
                to = 0; next = false;
                return false;
            }

            Point clientPoint = grid.PointToClient(new Point(e.X, e.Y));

            // 上下のみに着目するため、横方向は無視する
            clientPoint.X = 1;
            DataGridView.HitTestInfo hit =
                grid.HitTest(clientPoint.X, clientPoint.Y);

            to = hit.RowIndex;
            if (to == -1)
            {
                int top = grid.ColumnHeadersVisible ? grid.ColumnHeadersHeight : 0;
                top += 1; // ...

                if (top > clientPoint.Y)
                    // ヘッダへのドロップ時は表示中の先頭行とする
                    to = grid.FirstDisplayedCell.RowIndex;
                else
                    // 最終行へ
                    to = grid.Rows.Count - 1;
            }

            // 追加用の行は無視
            if (to == grid.NewRowIndex) to--;

            next = (to > from);
            return (from != to);
        }
开发者ID:Ricordanza,项目名称:Ricordanza.kernel,代码行数:48,代码来源:CoreDataGridView.cs


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