private void gridControl1_MouseDown(object sender, MouseEventArgs e) { int row, col; Point pt = new Point(e.X, e.Y); if(this.gridControl1.PointToRowCol(pt, out row, out col, -1)) { Console.WriteLine(string.Format("gridControl1_MouseDown {0},{1}", row, col)); } }
private void gridControl1_CellHitTest(object sender, GridCellHitTestEventArgs e) { //get them everywhere e.Result = 1; }
>private void gridControl1_CellHitTest(object sender, GridCellHitTestEventArgs e) >{ > //get them everywhere > e.Result = 1; >} >Thanks for replaying! after add CellHitTest, it did hit the CellMouseDown. however i still got some problems. My requirement is to select several cells in virtualgrid, then change the values for the selected cells. After i recorded the cell row and colum index use cellMouseDown event, move the mouse to some other cell, then tried to use CellMouseUp event to get the mouse pointed cell info.(rowIndex and colIndex), it still gave the cell info. where mouse was down. what''s the problem here? is there any other ways that i can achieve my requirement? private void gridControl1_CellMouseDown(object sender, Syncfusion.Windows.Forms.Grid.GridCellMouseEventArgs e) { this.rowSelectBegin = e.RowIndex; this.columSelectBegin = e.ColIndex; } private void gridControl1_CellMouseUp(object sender, Syncfusion.Windows.Forms.Grid.GridCellMouseEventArgs e) { this.rowSelectStop = e.RowIndex; this.columSelectStop = e.ColIndex ; }
Point pt = new Point(e.MouseEventArgs.X,e.MouseEventArgs.Y);
int row, col;
this.gridControl1.PointToRowCol(pt, out row, out col, -1);
>Point pt = new Point(e.MouseEventArgs.X,e.MouseEventArgs.Y);
>int row, col;
>this.gridControl1.PointToRowCol(pt, out row, out col, -1);
>
Thank you very much Clay, it works fine.
another question, if i want to change the selected cells backcolor(some highlight effect) in virtualgrid, what am i going to do.
I tried the following code, i does not change the color but the value!
private int rowSelectBegin = -1, rowSelectStop = -1, columSelectBegin = -1, columSelectStop = -1;
private void gridControl1_CellMouseDown(object sender, Syncfusion.Windows.Forms.Grid.GridCellMouseEventArgs e)
{
Point pt = new Point(e.MouseEventArgs.X,e.MouseEventArgs.Y);
this.gridControl1.PointToRowCol(pt, out rowSelectBegin , out columSelectBegin, -1);
}
private void gridControl1_CellMouseUp(object sender, Syncfusion.Windows.Forms.Grid.GridCellMouseEventArgs e)
{
Point pt = new Point(e.MouseEventArgs.X,e.MouseEventArgs.Y);
this.gridControl1.PointToRowCol(pt, out rowSelectStop , out columSelectStop, -1);
for(int i = rowSelectBegin; i< rowSelectStop; i++)
{
this.gridControl1[i,columSelectBegin-1].BackColor = Color.Azure;
}
}