Fires when a user clicks a data cell. If data is editable and the ColumnViewOptionsBehavior.EditorShowMode property equals MouseDown (or Default, if multiple row selection is disabled), the event is suppressed.

Namespace:DevExpress.XtraGrid.Views.Grid  
Assembly:DevExpress.XtraGrid.v19.1.dll

Syntax

C#: public event RowCellClickEventHandler RowCellClick

VB: event Public RowCellClick As RowCellClickEventHandler

Event Data

The event handler receives an argument of type RowCellClickEventArgs containing data related to this event.

The following RowCellClickEventArgs properties provide information specific to this event.

Property Description
Button Gets which mouse button was pressed.
CellValue Gets the edit value of the clicked cell.
Clicks Gets the number of times the mouse button was pressed and released.
Column Gets the column that contains the clicked cell.
Delta Gets a signed count of the number of detents the mouse wheel has rotated. A detent is one notch of the mouse wheel.
Handled Gets or sets a value specifying whether an event has been handled.
HitInfo Gets an object that identifies the clicked element.
IsHMouseWheel This member supports the internal infrastructure, and is not intended to be used directly from your code.
IsMouseEvent Gets whether these event arguments provide data for the MouseUp, MouseDown, and MouseMove events.
Location Gets the location of the mouse during the generating mouse event.
RowHandle Gets the handle of the clicked row.
X Gets the x-coordinate of the mouse during the generating mouse event.
Y Gets the y-coordinate of the mouse during the generating mouse event.        

Remarks

The RowCellClick event does not fire when a user clicks on a row cell if Grid data is editable and the ColumnViewOptionsBehavior.EditorShowMode property is set to MouseDown (or to Default, if multiple row selection is disabled).

The HitInfo parameter is not initialized when this event fires. Use the BaseView.CalcHitInfo method to get a HitInfo object.

Example

In this example, the Data Grid is in non-editable mode (does not invoke cell editors when users click them). Cells under the "State" column cycle through all "ObjectState" enumerator values when a user clicks these cells.

using System.Collections.Generic;
using System.Windows.Forms;
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Views.Grid;

namespace DXApplication3
{
    public partial class Form1 : DevExpress.XtraEditors.XtraForm {
        public Form1() {
            InitializeComponent();
            //add Data Grid 
            GridControl gridControl = new GridControl { Parent = this, Dock = DockStyle.Fill };
GridView gridView = new GridView();
            gridView.OptionsBehavior.Editable = false;
            gridControl.MainView = gridView;
            //bind to sample data 
            List<SomeObject> dataSource = new List<SomeObject>();
            for (int i = 0; i < 4; i++)
                dataSource.Add(new SomeObject { Name = string.Format("Object{0}", i), State = (ObjectState)i });
            gridControl.DataSource = dataSource;

            gridView.RowCellClick += gridView_RowCellClick;
        }

        //when a user clicks any "State" column cell, the cell should change its value 
        void gridView_RowCellClick(object sender, RowCellClickEventArgs e) {
            if (e.Column.FieldName == "State") {
                ObjectState state = (ObjectState)e.CellValue;
                ObjectState newState;
                switch (state) {
                    case ObjectState.Normal:
                        newState = ObjectState.Selected;
                        break;
                    case ObjectState.Selected:
                        newState = ObjectState.Highlighted;
                        break;
                    case ObjectState.Highlighted:
                        newState = ObjectState.Hovered;
                        break;
                    default:
                        newState = ObjectState.Normal;
                        break;
                }
                GridView view = sender as GridView;
                view.SetRowCellValue(e.RowHandle, e.Column, newState);
            }
        }

        //sample data entity 
        public class SomeObject {
            public string Name { get; set; }
            public ObjectState State { get; set; }
        }

        //available values for the "State" column cells 
        public enum ObjectState {
            Normal,
            Selected,
            Highlighted,
            Hovered
        }
    }
}

最新文章

  1. 安装Ubuntu的那些事儿(续)
  2. 77 swapoff-关闭系统交换区
  3. iOS常用设计模式笔记
  4. hadoop小试
  5. Ajax跨域请求ashx文件与Webservice文件
  6. JMeter学习(二十五)HTTP属性管理器HTTP Cookie Manager、HTTP Request Defaults
  7. zookeeper分布式环境的搭建
  8. 预定义宏__GNUC__和_MSC_VER
  9. MP4(一)-结构
  10. 查看oracle 启动了多久
  11. 浅谈.Net和Java互相调用的三种方式
  12. memcache 和 redis 之间的区别
  13. 腾讯面试:一条SQL语句执行得很慢的原因有哪些?---不看后悔系列
  14. string与number转换
  15. 汉明码(Hamming)编码与纠错原理
  16. DateUtils时间单元说明
  17. Python 【web框架】之Flask
  18. Hive的UDF是什么?
  19. marquee标签详解
  20. HDFS的客户端操作

热门文章

  1. JAVA虚拟机02---JAVA虚拟机运行时数据区域简介
  2. 下午小博(java小知识)
  3. javaEE(多线程、线程通信、线程安全、线程池、线程池工具)
  4. 【KAWAKO】speechmetrics-语音方面评价指标库的安装与使用
  5. 使用一个文件集中管理你的 Nuget 依赖版本号
  6. C语言初学习
  7. Centos7-RAID冗余磁盘阵列
  8. css3自动滚动
  9. TextView 走马灯效果不生效
  10. LeetCode-2100 适合打劫银行的日子