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.
Syncfusion Feedback

Retrieve Selected row and located cells in the row

Thread ID:

Created:

Updated:

Platform:

Replies:

110003 Jul 15,2013 11:22 PM UTC Mar 27,2018 07:16 AM UTC WinForms 3
loading
Tags: GridControl
Yu
Asked On July 15, 2013 11:22 PM UTC

Hi,
 
I am very new to the GridControl.
 
After the GridControl is populated with a collection of data through the adaptor and displayed on the screen, when any row is selected in the GridControl, how could I get hold of the selected Row?
 
I would also need to change the background color of the cell. e.g. The second cell of the selected row when the row is selected.
 
I am using C# and Windform.
 
Thanks

Arun Kumar V [Syncfusion]
Replied On July 18, 2013 04:01 AM UTC

Hi YU,

Thanks for your interest in Syncfusion products.

Query:

GridControl backcolor change.

 

The selected row can be achieved in many ways. Please refer to the following UG which is similar to your inquiry.

http://help.syncfusion.com/ug/windows%20forms/grid/default.htm#!documents/5137howcanwemakethecurrentrowbold.htm

You can use the CurrentCellChanged and CurrentCellValidateString events to capture the current cell text also when the text changed is changed.

Code snippet:

1.)

this.gridControl1.CurrentCellChanged += new EventHandler(gridControl1_CurrentCellChanged);

private void gridControl1_CurrentCellChanged(object sender, System.EventArgs e)

{

GridCurrentCell cc = this.gridControl1.CurrentCell; Console.WriteLine("CurrentCellChanged :" + cc.Renderer.ControlText);   

}

this.gridControl1.CurrentCellValidateString += new GridCurrentCellValidateStringEventHandler(gridControl1_CurrentCellValidateString);

private void gridControl1_CurrentCellValidateString(object sender, Syncfusion.Windows.Forms.Grid.GridCurrentCellValidateStringEventArgs e)

{

GridCurrentCell cc = this.gridControl1.CurrentCell; Console.WriteLine("CurrentCellValidateString :" + cc.Renderer.ControlText);  

}

2.)

You can get the updated value by using AcceptedChanges event. Please refer to the following code.

this.gridControl1.CurrentCellAcceptedChanges += new CancelEventHandler(gridControl1_CurrentCellAcceptedChanges);

this.gridControl1.CurrentCellDeactivated += newGridCurrentCellDeactivatedEventHandler(gridControl1_CurrentCellDeactivated);

this. gridControl1.CurrentCellValidating += newCancelEventHandler(gridControl1_CurrentCellValidating);

void gridControl1_CurrentCellAcceptedChanges(object sender,CancelEventArgs e)

{

}

void gridControl1_CurrentCellValidating(object sender,CancelEventArgs e)

{

}

void gridControl1_CurrentCellDeactivated(object sender,GridCurrentCellDeactivatedEventArgs e)

{

}

3.)

//Occurs before the current cell switches into editing mode

this.gridControl1.CurrentCellStartEditing += newCancelEventHandler(gridControl1_CurrentCellStartEditing);

//Occurs when the grid completes editing mode, i.e., when the active current cell exits the editing mode

this.gridControl1.CurrentCellEditingComplete += newEventHandler(gridControl1_CurrentCellEditingComplete);

//Occurs when the grid accepts changes made to the active current cell

this.gridControl1.CurrentCellAcceptedChanges += newCancelEventHandler(gridControl1_CurrentCellAcceptedChanges);

 

Please let me know if you have any concerns.

Regards,

Arun.


Phien Le
Replied On March 26, 2018 08:42 AM UTC

Hi YU,

Thanks for your interest in Syncfusion products.

Query:

GridControl backcolor change.

 

The selected row can be achieved in many ways. Please refer to the following UG which is similar to your inquiry.

http://help.syncfusion.com/ug/windows%20forms/grid/default.htm#!documents/5137howcanwemakethecurrentrowbold.htm

You can use the CurrentCellChanged and CurrentCellValidateString events to capture the current cell text also when the text changed is changed.

Code snippet:

1.)

this.gridControl1.CurrentCellChanged += new EventHandler(gridControl1_CurrentCellChanged);

private void gridControl1_CurrentCellChanged(object sender, System.EventArgs e)

{

GridCurrentCell cc = this.gridControl1.CurrentCell; Console.WriteLine("CurrentCellChanged :" + cc.Renderer.ControlText);   

}

this.gridControl1.CurrentCellValidateString += new GridCurrentCellValidateStringEventHandler(gridControl1_CurrentCellValidateString);

private void gridControl1_CurrentCellValidateString(object sender, Syncfusion.Windows.Forms.Grid.GridCurrentCellValidateStringEventArgs e)

{

GridCurrentCell cc = this.gridControl1.CurrentCell; Console.WriteLine("CurrentCellValidateString :" + cc.Renderer.ControlText);  

}

2.)

You can get the updated value by using AcceptedChanges event. Please refer to the following code.

this.gridControl1.CurrentCellAcceptedChanges += new CancelEventHandler(gridControl1_CurrentCellAcceptedChanges);

this.gridControl1.CurrentCellDeactivated += newGridCurrentCellDeactivatedEventHandler(gridControl1_CurrentCellDeactivated);

this. gridControl1.CurrentCellValidating += newCancelEventHandler(gridControl1_CurrentCellValidating);

void gridControl1_CurrentCellAcceptedChanges(object sender,CancelEventArgs e)

{

}

void gridControl1_CurrentCellValidating(object sender,CancelEventArgs e)

{

}

void gridControl1_CurrentCellDeactivated(object sender,GridCurrentCellDeactivatedEventArgs e)

{

}

3.)

//Occurs before the current cell switches into editing mode

this.gridControl1.CurrentCellStartEditing += newCancelEventHandler(gridControl1_CurrentCellStartEditing);

//Occurs when the grid completes editing mode, i.e., when the active current cell exits the editing mode

this.gridControl1.CurrentCellEditingComplete += newEventHandler(gridControl1_CurrentCellEditingComplete);

//Occurs when the grid accepts changes made to the active current cell

this.gridControl1.CurrentCellAcceptedChanges += newCancelEventHandler(gridControl1_CurrentCellAcceptedChanges);

 

Please let me know if you have any concerns.

Regards,

Arun.


you agree to the privacy policy and terms of service.

Sindhu Nagarajan [Syncfusion]
Replied On March 27, 2018 07:16 AM UTC

Hi Phien, 

Thanks for the update. 

Please explain your queries with some more details, so that we will be able to assist you. 

Regards, 
Sindhu  


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.

Warning Icon 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.Close Icon

;