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. Image for the cookie policy date

How to allow 1 column to edit while keeping other columns readonly State?

Hi Team,
 
I want to Edit 1 column in the GridGroupingControl, I want to operate like this:
 
1. 1  special column can be edited;
2. We can get how many rows are modified(the row Indexes ,or modified row data as List<T>);
3. if I use the code: "gridGroupingControl1.TableOptions.AllowSelection = GridSelectionFlags.Cell;", the background-color of the selected rows is Black, how to set the bg-color to blue or yellow?
 
Could you help realize above features?
 
attach is my code, could you review my code and give suggestions?
 
Thanks,
Yujing
 

Attachment: EditColumnInGridGroupingControl_dffe3ec4.rar

6 Replies

YW Yujin Wu January 19, 2015 01:32 PM UTC

Hi Team,
 
Please use my new-uploaded project. thanks.

Attachment: EditColumnInGridGroupingControl_89af4674.rar


MK Muthukumar Kalyanasundaram Syncfusion Team January 20, 2015 05:53 PM UTC

Hi Yujing,

 

Thank you for your interest in Syncfusion products.

 

 

Query 1

1  special column can be edited

 

 

If you want to edit a column in a grid, you can use “AllowEdit” property as true. Please refer the below code,

 

Code:

gridGroupingControl1.TableDescriptor.AllowEdit = true;            gridGroupingControl1.Table.TableDescriptor.Columns[0].ReadOnly = true;            gridGroupingControl1.Table.TableDescriptor.Columns[1].ReadOnly = false;

gridGroupingControl1.Table.TableDescriptor.Columns[2].ReadOnly = true

 

 

Query 2

Modified data row index in a grid

 

 

If you want to modified data row index in a grid, you can use “TableControlCurrentCellEditingComplete”event. Please refer the below code,

 

Code:

this.gridGroupingControl1.TableControlCurrentCellEditingComplete += new GridTableControlEventHandler(gridGroupingControl1_TableControlCurrentCellEditingComplete);

void gridGroupingControl1_TableControlCurrentCellEditingComplete(object sender, GridTableControlEventArgs e)

{

GridCurrentCell cc = this.gridGroupingControl1.TableControl.CurrentCell;

MessageBox.Show("Row "+cc.RowIndex.ToString()+", Column" +cc.ColIndex.ToString());

}

 

 

Query 3

background-color of the selected rows in a grid

 

 

If you want to change the selected row back color in a grid, you can use “SelectionBackColor” property. Please refer the below code,

 

Code:

gridGroupingControl1.TableOptions.AllowSelection = GridSelectionFlags.Any | GridSelectionFlags.Row;

gridGroupingControl1.TableOptions.ListBoxSelectionCurrentCellOptions = GridListBoxSelectionCurrentCellOptions.MoveCurrentCellWithMouse;

gridGroupingControl1.TableOptions.ListBoxSelectionMode = SelectionMode.One;

gridGroupingControl1.TableOptions.SelectionBackColor = Color.Yellow;

 

 

Please let us know if you have any concern.

 

Regards,

Muthukumar K


Attachment: Edit_a_column_32669937.zip


YW Yujin Wu January 21, 2015 02:48 AM UTC

Hi Team,
 
Appreciated for your feedback, and it resoved back-color issue for the edited-row.
 
However, we want to clear any styles for the selected row after save the gird.
 
Please find the images in the VS project.
 
Waiting for your resolution...
 
Thanks,
Yujin

Attachment: Edit_a_column_ee0a8c58.rar


MK Muthukumar Kalyanasundaram Syncfusion Team January 21, 2015 04:14 PM UTC

Hi Yujin,

 

Thanks for the update.

 

If you want to clear the style of selected row after editing completed in a cell, you can use Selections.Clear() method. Please refer the below code,

 

Code:

private void button3_Click(object sender, EventArgs e)

{

this.gridGroupingControl1.TableControl.Selections.Clear();

this.gridGroupingControl1.Refresh();

}

 

Please let us know if you have any concern.

 

Regards,

Muthukumar K


Attachment: Selection_Clear_93cfec3a.zip


YW Yujin Wu January 22, 2015 10:32 AM UTC

Hi Muthukumar ,
 
It resolved my issue, appreciated for your quickly-update.
 
Thanks,
Yujin


MK Muthukumar Kalyanasundaram Syncfusion Team January 23, 2015 03:37 AM UTC

Hi Yujin,

 

We are glad to hear that the reported issue has been resolved. Please let us know if you need any further assistance.

 

Regards,

Muthukumar K


Loader.
Live Chat Icon For mobile
Up arrow icon