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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Merged Cell Data Validation

Thread ID:





92062 Dec 16,2009 09:25 PM UTC Dec 17,2009 09:08 AM UTC WinForms 3
Tags: XlsIO
Adrian Gingell
Asked On December 16, 2009 09:25 PM UTC


I have been experiencing problems trying to attach data validation to merged cells. The code below merges 3 cells and then assigns a simple list of values as a drop-down. All seems fine until the workbook is saved at which point an exception is reported with the message: "An entry with the same key already exists".

For testing purposes the following code can be added to your DataValidation_2005 sample WinForm solution.


sheet.Range["F7:H7"].CellStyle.Borders.LineStyle = ExcelLineStyle.Medium;
sheet.Range["F7:H7"].CellStyle.Borders[ExcelBordersIndex.DiagonalDown].ShowDiagonalLine = false;
sheet.Range["F7:H7"].CellStyle.Borders[ExcelBordersIndex.DiagonalUp].ShowDiagonalLine = false;

IDataValidation v = sheet.Range["F7:H7"].DataValidation;
v.ListOfValues = new string[] { "A", "B", "C" };
v.PromptBoxText = "Data Validation list";
v.IsPromptBoxVisible = true;
v.ShowPromptBox = true;
v.IsEmptyCellAllowed = false;
v.ErrorBoxTitle = "Invalid Selection";
v.ErrorBoxText = "Please select a value from the drop down list.";
v.ErrorStyle = ExcelErrorStyle.Stop;




Lokesh R [Syncfusion]
Replied On December 17, 2009 04:30 AM UTC

Hi Adrian,

Thank you for your interest on Syncfusion Products.

I have made certain modifications on your code.please try the following code.

//No need to give the data range again for the validation,because you have already merged the cells //

IDataValidation v = sheet.Range["F7"].DataValidation;


Let me know if you have any queries.



Adrian Gingell
Replied On December 17, 2009 08:57 AM UTC

Great, that works! Thanks very much for the quick response.


Lokesh R [Syncfusion]
Replied On December 17, 2009 09:08 AM UTC

Hi Adrian,

Thank you for your interest on Syncfusion Products.

You are welcome.




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.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon 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.Close Icon