Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
reference frame caption associated with a checkbox | Excel Programming | |||
.BackColor of CheckBox only extends as far as the text in the caption | Excel Programming | |||
how to execute a macro assigned to a checkbox in vba | Excel Programming | |||
Adding CheckBox Caption to a Listbox | Excel Programming | |||
Excel VBA - Capturing a checkbox caption into a worksheet. | Excel Programming |