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.

Convert GridRangeInfo to Excel String Range

Thread ID:





130763 May 31,2017 06:24 PM Jun 5,2017 05:51 AM Windows Forms 5
Tags: GridControl
Chris Bishop
Asked On May 31, 2017 06:24 PM

Hi,  I am working with GridRangeInfo to create ranges and also working with NamedRanges and need a way to convert from GridRangeInfo into "A1:B1" format.


                 var engine = ((GridFormulaCellModel) gridControl1.Model.CellModels["FormulaCell"]).Engine;
                 engine.AddNamedRange("Test", GridRangeInfo.Cells(1,1,2,2).Info);
                 var name = engine.NamedRangeValues.Values.OfType<String>().Single(s => s == "A1:B2");

Basically I want to convert between "A1:B2" format and GridRangeInfo.


Arulpriya Ramalingam [Syncfusion]
Replied On June 1, 2017 06:03 AM

Hi Chris, 

Thanks for your interest in Syncfusion products. 

We could able to understand your scenario. As per our current support of GridControl, the NamedRanges can be passed only as AlphaLabel ranges. So GridControl does not have direct support to convert the GridRangeInfo(i.e R1C2) to named ranges (i.e., A1).  Please refer the NamedRanges UG link to know more about NamedRanges. The reported scenario can be achieved by using GetAlphaLabel() method. GetAlphaLabel() can be used to get the AlphaLabel of the column. Please make use of below code and sample, 

Code snippet 
var engine = ((GridFormulaCellModel)gridControl1.Model.CellModels["FormulaCell"]).Engine; 
//To Pass the GridRange 
GridRangeInfo range = GridRangeInfo.Cells(1, 1, 2, 2); 
int topIndex = range.Top; 
int rightIndex = range.Right; 
//To get the alpha label for the cells 
string startAlpha = GridRangeInfo.GetAlphaLabel(range.Left); 
string endAlpha = GridRangeInfo.GetAlphaLabel(range.Right); 
//To convert the GridRange into AlphaLabelRange 
var namedRange = startAlpha + topIndex + ":" + endAlpha + rightIndex; 
//To add the namedrange 
engine.AddNamedRange("Test", namedRange); 


Chris Bishop
Replied On June 1, 2017 09:27 AM

That is not acceptable.Your offer a GridControl that supports excel ranges in string format but use your own object for handling ranges in code and then do not provide a way to switch between them.  This is ludicrous that you expect the developer to create their own conversion method.  I need to switch between the two.If you don't have this feature it needs to be added.

Arulpriya Ramalingam [Syncfusion]
Replied On June 2, 2017 04:33 AM

Hi Chris, 
Thanks for your update. 
We have created the separate incident for the reported scenario for better follow-up under your account. Please follow-up with that incident. 

Chris Bishop
Replied On June 2, 2017 09:40 AM

Thank you,

I appreciate that.

Arulpriya Ramalingam [Syncfusion]
Replied On June 5, 2017 05:51 AM

Hi Chris,  

Thanks for your appriciation. 



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.