Checkbox displays 'check' instead of the assigned caption
Hi,
I added a checkbox using the following code in C# private void AddCheckbox(RectangleF location, string caption) { OLEObjects all = (OLEObjects) activeWorksheet.OLEObjects(Type.Missing); OLEObject obj = all.Add("Forms.CheckBox.1", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, location.X, location.Y, location.Width, location.Height); Object[] text = new object[] { caption }; obj.Object.GetType().InvokeMember("Caption", BindingFlags.SetProperty, null, obj.Object, text); text[0] = true; obj.Object.GetType().InvokeMember("FontBold", BindingFlags.SetProperty, null, obj.Object, text); obj.Object.GetType().InvokeMember("Value", BindingFlags.SetProperty, null, obj.Object, text); Marshal.ReleaseComObject(all); Marshal.ReleaseComObject(obj); } And it works, but when the sheet is displayed, the caption of the checkbox is 'check', and the checkbox appears unselected. If I click on the checkbox, then the correct caption appears, and the checkbox briefly displays as checked before becoming unchecked. How do I get it to display correctly without the user clicking on it? |
All times are GMT +1. The time now is 05:48 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com