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.

Grid Control - Adding Column

Thread ID:

Created:

Updated:

Platform:

Replies:

66935 Aug 6,2007 05:29 AM Aug 9,2007 08:17 PM Windows Forms 3
loading
Tags: GridControl
Vivek Vashisht
Asked On August 6, 2007 05:29 AM

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

haneefm [Syncfusion]
Replied On August 6, 2007 11:40 AM

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

Vivek Vashisht
Replied On August 9, 2007 01:55 AM

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

haneefm [Syncfusion]
Replied On August 9, 2007 08:17 PM

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

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.

;