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
close icon

Grid Control - Adding Column

Hi,

I am using Grid Control. I have provided a context menu through which the user can perform certain operations.

1. Can you please tell how can I add a checkbox column dynamically on click of one of the menu options to the grid control?

2. How can I perform sorting of only the selected values in the grid control? For example I have 10 rows in the grid Control, I select rows 3,4,5,6 and from the context menu click 'Sort'. On click of sort only the selected values should get sorted and not the other ones.

Can you please provide some code to accomplish the tasks.

Thanks
Vivek

3 Replies

HA haneefm Syncfusion Team August 6, 2007 03:40 PM UTC

Hi Vivek,

1. Can you please tell how can I add a checkbox column dynamically on click of one of the menu options to the grid control?
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

In your contextMenu click evebt, You can try setting the properties by accessing the styleInfo properties through Model and set the CellType,CellValueType and CheckboxOptions properties to see if that helps.

grid.Model.ColCount += 1;// Add the extra column to grid.
grid.Refresh();

//set the new added colum to "checkBox";
grid.Model.Colstyles[ grid.ColCount].CellType = "CheckBox"
grid.Model.Colstyles[ grid.ColCount].CellValueType = typeof(bool);
grid.Model.Colstyles[ grid.ColCount].CheckBoxOptions = new Syncfusion.Windows.Forms.Grid.GridCheckBoxCellInfo(true.ToString(), false.ToString(), "", true);

You can get the value of the checkbox cell using the below code:

object obj = grid.Model[ rowindex, checkBoxcolumnIndex].CellValue;

2. How can I perform sorting of only the selected values in the grid control? For example I have 10 rows in the grid Control, I select rows 3,4,5,6 and from the context menu click 'Sort'. On click of sort only the selected values should get sorted and not the other ones.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Here is a minimal sample that shows you "How to freeze the rows on sorting in a simple gridcontrol?".
http://www.syncfusion.com/support/forums/message.aspx?&MessageID=57901

Best regards,
Haneef


VV Vivek Vashisht August 9, 2007 05:55 AM UTC

Haneef,

The adding column thing worked, thanks for your help.

But the sorting example that you provided is not exactly what i require...
Your sample seems to assume that certain rows will always remain freezed, where as thats not the case with my requirement. My requirement is that the user selects the rows by dragging the mouse and from a context menu option of 'Sort', is able to perform sorting of the selected values only with out affecting the other values.

To re-create this, you can refer to an excel sheet, write a few random numeric values in one column, select only a few rows in that column and click 'Sort Ascending'/'Sort Descending' button. You will notice that only the selected values have been sorted. My requirements are exactly the same.

Is there any mechanism through which I can provide the selected range to the sort method. Can you please provide some sample code for me to able to accomlpish the objective here.

Thanks
Vivek


HA haneefm Syncfusion Team August 10, 2007 12:17 AM UTC

Hi Vivek,

Here is a minimal sample that shows you "How to sort the selected ranges in a grid?".please try this and let me know if this helps.
GridPopulateM.zip

Best regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon