This project is read-only.

Checkbox in Cell Error: Models.ICheckBox not found

Jul 3, 2012 at 11:31 PM

I added a checkbox to a column (cell).  The checkbox works fine, however, when I double click on or move the column separator, I get a fault.

What can be the problem?

Error Details:

 Models.ICheckBox not found


Target Site
 {Void UIChangeChecked(SourceGrid.CellContext, System.EventArgs)}

Stack Trace
   at SourceGrid.Cells.Controllers.CheckBox.UIChangeChecked(CellContext sender, EventArgs e)
   at SourceGrid.Cells.Controllers.CheckBox.OnClick(CellContext sender, EventArgs e)
   at SourceGrid.Cells.Controllers.ControllerContainer.OnClick(CellContext sender, EventArgs e)
   at SourceGrid.GridVirtual.OnMouseClick(MouseEventArgs e)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason,

Source to Add a Checkbox

// Code to set a checkbox in a column
Boolean bCellValue = false;
Boolean bSuccess = false;
if (null == oData[iColumn])
bCellValue = false;
bSuccess = Boolean.TryParse(oData[iColumn].ToString(), out bCellValue);
this.ctlTable[iRow, iColumn + this.ColumnIndexOffset] = new SourceGrid.Cells.CheckBox(null, bCellValue);
this.ctlTable[iRow, iColumn + this.ColumnIndexOffset].View = new SourceGrid.Cells.Views.CheckBox();
this.ctlTable[iRow, iColumn + this.ColumnIndexOffset].Editor.EnableEdit = !this.m_ColumnReadOnly[iColumn];

// I am overwriting one class, so that I can get at the CheckedChange event.  Following in class constructor.  ctlTable is the grid control.
this.ctlTable.Controller.AddController(new CheckedChangedEvent(this));

// CheckedChanged Code
		public class CheckedChangedEvent : SourceGrid.Cells.Controllers.CheckBox
			// Member Variables
			Spread m_oSpread = null;

			public CheckedChangedEvent(Spread oSpread)
				// Save the main spread control argument.
				this.m_oSpread = oSpread;

				// Attach to the event.
				base.CheckedChanged += new EventHandler(CheckedChangedEvent_CheckedChanged);

			public void CheckedChangedEvent_CheckedChanged(object sender, EventArgs e)
				// Raise of the event.
				if (null != this.m_oSpread.CheckedChanged)
					// Fire off the event.
					this.m_oSpread.CheckedChanged(this, new EventArgs());

					// Get the position of the checkbox.
					SourceGrid.Position oPos = new SourceGrid.Position(this.m_oSpread.ActiveRow, this.m_oSpread.ActiveCol + this.m_oSpread.ColumnIndexOffset);

					// For whatever reason the checkbox no longer changes state, so do that now.
					if (true == this.m_oSpread.ctlTable[oPos].Editor.EnableEdit)
						Boolean bChecked = ((Boolean)this.m_oSpread.ctlTable[oPos].Value);
						this.m_oSpread.ctlTable[oPos].Value = !bChecked;



Jul 11, 2012 at 12:37 AM

I solved my own problem.   When creating the checkbox, I had to add an IModel.  Also, the addition of the control is not done in the constructor for parent control, but rather adding to the checkbox.  Cell.Controller.AddControler().

I also had to create a ICheckBox class for the model.