GridGroupingControl select a cell and set the cursor position or highlight the value
Thank you for using Syncfusion products.
|
Query-1 How can I get the code to select the cell with cursor blinking at the end position? |
If you want to set the record with cursor at end position of the cell, you can use the CurrentCell.MoveTo method instead of using SetCurrent method of record. After moving the CurrentCell to particular cell, you can set the cursor at end position by using CurrentCell.Renderer. Please make use of below code,
Code Snippet: private void moveBtn_Click(object sender, EventArgs e) { //Set your needed column index int colIndex = this.gridGroupingControl1.TableDescriptor.FieldToColIndex(0);
//Getting the record rowIndex based on its position int rowIndex = this.gridGroupingControl1.Table.Records[0].GetRowIndex();
//Moving the current cell this.gridGroupingControl1.TableControl.CurrentCell.MoveTo(rowIndex, colIndex, Syncfusion.Windows.Forms.Grid.GridSetCurrentCellOptions.SetFocus); this.gridGroupingControl1.Focus();
//Setting the cursor at end position of cell if (this.gridGroupingControl1.TableControl.CurrentCell.Renderer is GridTextBoxCellRenderer) { GridTextBoxCellRenderer renderer = this.gridGroupingControl1.TableControl.CurrentCell.Renderer as GridTextBoxCellRenderer; renderer.TextBox.SelectionStart = renderer.TextBox.Text.Length; } } |
|
Query-2 How can I get the code to highlight the CellValue? |
If you want to highlight the cellvalue in cell, you can use renderer.TextBox.SelectAll() method instead of using renderer.TextBox.SelectionStart.
Code Snippet: //Highlighting the cellvalue if (this.gridGroupingControl1.TableControl.CurrentCell.Renderer is GridTextBoxCellRenderer) { GridTextBoxCellRenderer renderer = this.gridGroupingControl1.TableControl.CurrentCell.Renderer as GridTextBoxCellRenderer; renderer.TextBox.SelectAll(); } |
Note:
In the below sample, we have provided the two buttons. If you press the “Moving with cursor at end” button, the currentcell will be moved to particular cell with cursor at end position. The currentcell will be moved with highlighting the cellvalue if you press the “Moving with CellValue highlighting” button.
Sample:
http://www.syncfusion.com/downloads/support/forum/119541/ze/Sample_CurrentCell_Move-686832298
Please let me know if you have any queries.
Regards,
Neelakandan
Thank you for your update.
We are glad to hear from you that your reported scenario has been achieved.
Please let us know if you need further assistance on this.
Regards,
Neelakandan
- 4 Replies
- 2 Participants
-
TT tttmack
- Jul 6, 2015 11:47 PM UTC
- Jul 9, 2015 04:11 AM UTC