Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
reference frame caption associated with a checkbox novice973 Excel Programming 2 April 8th 08 11:53 PM
.BackColor of CheckBox only extends as far as the text in the caption [email protected] Excel Programming 0 October 31st 06 11:14 PM
how to execute a macro assigned to a checkbox in vba [email protected] Excel Programming 4 June 21st 06 09:31 AM
Adding CheckBox Caption to a Listbox Peterd Excel Programming 2 August 22nd 05 01:03 PM
Excel VBA - Capturing a checkbox caption into a worksheet. rott[_9_] Excel Programming 1 June 19th 04 07:43 PM


All times are GMT +1. The time now is 08:11 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"