We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

GridGroupingControl select a cell and set the cursor position or highlight the value

Thread ID:

Created:

Updated:

Platform:

Replies:

119541 Jul 6,2015 07:47 PM Jul 9,2015 12:11 AM Windows Forms 4
loading
Tags: GridGroupingControl
tttmack
Asked On July 6, 2015 07:47 PM


Hello, I would like to be able to select a cell in my grid grouping control and set the cursor position (second image below) or highlight the cell value (third image below).

I have the code below, but it only selects the cell and does not achieve what I want (first image below):

Record record = GetRecord(id);
record.ParentTable.CurrentRecordManager.CurrentField = gridGroupingControl1.TableDescriptor.Fields[2];
record.SetCurrent();

Can you please let me know what I would have to do to get the code to work like the 2nd and 3rd screenshots (I did those manually but would like to know how to do them programatically)?

Thanks for your help!



tttmack
Replied On July 6, 2015 07:48 PM


Neelakandan Kannan [Syncfusion]
Replied On July 7, 2015 07:27 AM

Hi Taylour,

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

tttmack
Replied On July 8, 2015 10:54 PM

thank you very much for your help Neelakandan!

Neelakandan Kannan [Syncfusion]
Replied On July 9, 2015 12:11 AM

Hi Taylour,

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;