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

Designer to format cells at runtime

Hi,

This is related to the configuration of cells at runtime.

We want the user to be able to select cells (not continuous cells but like in Excel user can select any number cells with Ctrl key) and then format the selected cells via some form of dialog box (provided by grid control).

There should be an option persist such format setting so that next time when user view/opens the control then format settings should be there.

The kind of format cells setting which we are expecting in dialog biox should be similar to what is provided by MS-Excel in Format Cells dialog box.

Can any body please tell me if all this can be achieved using grid control.

Thanks,
Vivek


3 Replies

SA Saravanan A Syncfusion Team June 4, 2007 08:45 PM UTC

Hi Vivek,

1, We want the user to be able to select cells and then format the selected cells via some form of dialog box
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Please refer to this small sample that shows how formatting can be applied to the selected cells, similar to Excel.
http://websamples.syncfusion.com/samples/Grid.Windows/F61840/main.htm

2, There should be an option persist such format setting
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
You can achieve this serializing the grid to a file, while closing the application and reload it from the form load event.
Please refer to the serialization sample that was shipped with our product. You can find it from the following location.
"\Syncfusion\EssentialStudio\5.1.0.51\Windows\Grid.Windows\Samples\2.0\Serialization\GridControl\cs"

Best Regards,
Saravanan


VV Vivek Vashisht June 5, 2007 11:19 AM UTC

Saravanan,

Thanks for the reply. But I was looking for something like a built in designer (Excel like) for formatting the cells.
None-the-less now i want to try a different approach. I would like to select a few random cells, right click and click onto the format cells option. This opens up a modal window which has a property grid. I have set propertygrid.selectedobject = gridControl.
Q1 -> When I change any property in the propertygrid, the change gets applied to the whole of the grid rather than just the selected cells. How can I make the change implemented only to the selected cells?
Q2 -> In the example that you provided me in your reply, you are setting each style entity of the list when apply button is clicked. Which property(s) of the propertygrid exposes the style that i can collectively apply to the selected cells instead of setting individual properties of the style object in the entity?

thanks
vivek

>Hi Vivek,

1, We want the user to be able to select cells and then format the selected cells via some form of dialog box
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Please refer to this small sample that shows how formatting can be applied to the selected cells, similar to Excel.
http://websamples.syncfusion.com/samples/Grid.Windows/F61840/main.htm

2, There should be an option persist such format setting
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
You can achieve this serializing the grid to a file, while closing the application and reload it from the form load event.
Please refer to the serialization sample that was shipped with our product. You can find it from the following location.
"\Syncfusion\EssentialStudio\5.1.0.51\Windows\Grid.Windows\Samples\2.0\Serialization\GridControl\cs"

Best Regards,
Saravanan


SA Saravanan A Syncfusion Team June 5, 2007 10:24 PM UTC

Hi Vivek,

Q1 -> How can I make the change implemented only to the selected cells?.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Try getting the combined style object for the selected cells using Model.GetCombinedStyle() method and asign it to the PropertyGrid.SelectedObject property.
Here is the code snippet.

GridRangeInfoList rangeList = null;
grid.Selections.GetSelectedRanges(out rangeList, true);
style = grid.Model.GetCombinedStyle(rangeList);
propertyGrid1.SelectedObject = style;


Q2 -> Which property(s) of the propertygrid exposes the style that i can collectively apply to the selected cells
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Try subscribe to the Changed event of the style object, that was asigned to the PropertyGrid and apply the changes to all the selected cells using Model.ChangeCells() method.

style.Changed += new StyleChangedEventHandler(GridStyleInfoChanged);
void GridStyleInfoChanged(object sender, StyleChangedEventArgs e)
{
if (!refreshPropertyGridNextIdle && range.Count != 0 && grid != null && style != null)
{
foreach (GridRangeInfo range in rangeList)
{
grid.Model.ChangeCells(range, style, StyleModifyType.Changes);
}
}
}


Best Regards,
Saravanan

Loader.
Live Chat Icon For mobile
Up arrow icon