Rogue Wave Knowledge Base
Search:    
Browse by category:
Knowledgebase | Glossary | Ask a Question |

Objective Grid: Toggling a checkbox

Article ID: 508
Last updated: 16 Apr, 2018
Revision: 2
print  Print
share  Share
Views: 32626
Posted: 09 Jan, 2001
by Meltreger B.
Updated: 16 Apr, 2018
by Meltreger B.

Problem


When using the CGXCheckListComboBox class, currently I have to click on the actual checkbox to toggle the value. How can I change the behavior so the checkbox is checked/unchecked whenever I click anywhere on the item?


Cause



Action


In order to do this, you should derive a class from CGXCheckListComboLBox (which itself derives from the MFC class CCheckListBox). In your subclass, you can process the WM_LBUTTONDOWN message as shown below. You will also have to subclass CGXCheckListComboBox class and override the CreateListBox member. There you should instantiate your CGXCheckListComboLBox derivative.

Example:

void CYourCheckListComboLBox::OnLButtonDown(UINT nFlags, CPoint point)
{
m_bLButtonDown = TRUE;
m_nOldSel = GetCurSel();
SetFocus();

// determine where the click is
BOOL bInCheck;
int nIndex = CheckFromPoint(point, bInCheck);

// if the item is disabled, then eat the click
if (!IsEnabled(nIndex))

return;
if (m_nStyle != BS_CHECKBOX && m_nStyle != BS_3STATE)
{
// toggle check mark automatically if check mark was hit
if (TRUE) //This was if(bInCheck) in the base class
{
CWnd* pParent = GetParent();
ASSERT_VALID(pParent);

int nModulo = (m_nStyle == BS_AUTO3STATE) ? 3 : 2;

int nCheck = GetCheck(nIndex);
nCheck = (nCheck == nModulo) ? nCheck - 1 : nCheck;
SetCheck(nIndex, (nCheck + 1) % nModulo);
InvalidateCheck(nIndex);
CListBox::OnLButtonDown(nFlags, point);

// Inform of check
pParent->SendMessage(WM_COMMAND,

MAKEWPARAM(GetDlgCtrlID(), CLBN_CHKCHANGE),
(LPARAM)m_hWnd);
return;
}
}

// do default listbox selection logic
CListBox::OnLButtonDown(nFlags, point);

}

This article was:   Helpful | Not helpful Report an issue


Prev     Next
Cell Attributes: Changing a read-only cell to be writable       Objective Grid: Changing the font of header cells

Others in this category
b Scroll with frozen columns
b GX_IDS_CTRL_TEXTFIT ComboBox wrong item selection if Formula Engine enabled
b Hide first column in CGXMRTGrid
b How to avoid cursor blinking on a grid view
b Objective Grid: The current DateTime control only displays the Date
b How to implement Cut method with a Virtual Grid
b Max and Min Date for Datetime Control in Grid for .Net
b Numeric Format in Grid for .Net
b Tab to Grid for .Net Control on a Form
b Loading Performance in Grid for .Net
b Objective Grid: Synchronizing cells in different views
b Objective Grid: Transferring data between a grid and a document
b Objective Grid: Floating, merge, and covered cells
b Objective Grid: Restricting printing to one page
b Objective Grid: Invalid page fault in module KERNEL32.DLL when exiting the application
b Objective Grid: Enabling listbox mode
b Objective Grid: Forcing [Tab] and [Return] keys to move to the next valid cell
b Objective Grid: Sorting columns and rows
b Objective Grid: Using covered cells as a recurring pattern
b Objective Grid: Limiting the drawing area of the grid
b Objective Grid: What is the best way to remove all rows for the entire grid?
b Objective Grid: Support for far-eastern languages
b Objective Grid: Preventing current cell deactivation during user selections
b Objective Grid: Cell edit notification
b Objective Grid: Drawing a bitmap and text into a grid cell with an edit control
b Objective Grid: Setting cells to be read-only.
b Objective Grid: Quicken-like grid
b Objective Grid: How to change the face color of a push button.
b Objective Grid: Excel compatibility
b Objective Grid: Optimally resizing columns when clicked
b Objective Grid: How can I specify the number of rows and columns in the grid?
b Objective Grid: Modifying status bar text during lengthy grid operations
b Objective Grid: Discarding the selection when the user changes the current cell
b Objective Grid: Assertion in COleDropTarget::Register()
b Locale settings in Objective Grid
b Objective Grid: Enabling row dragging
b Cell Attributes: Determining the attributes of a cell
b Objective Grid: Printing without grid lines
b Objective Grid: Printing a range of rows
b I have a grid with a CString
b Objective Grid: Restricting hint information when a view attached to a document is updated
b Objective Grid: Using a CGXTabWnd in a static splitter window
b Objective Grid: User Attributes
b Objective Grid: Determining the database field displayed in a column
b Objective Grid: Changing the default printer settings
b Objective Grid: Row height/column width not stored correctly after changing the standard font
b Objective Grid: Numeric entry in an edit cell
b Objective Grid: Displaying bitmaps
b Objective Grid: Disabling column resizing
b Objective Grid: How can I get the value for a given cell.
b Objective Grid: Disabling scrolling for the grid
b Objective Grid: Navigation notification
b Objective Grid: Changing cell styles when using a browser grid
b Objective Grid: Decreasing update flicker
b Objective Grid: Determining scroll bar visibility
b Objective Grid: What is the fastest way to clear cell contents out of the grid?
b Objective Grid: Increasing the thickness of the line separating columns
b Objective Grid: Disabling cell-range selection
b Objective Grid: Clearing the selection when the user moves the active cell
b Objective Grid: Removing borders from cells
b Objective Grid: Applying borders to cells
b Objective Grid: Dotted grid lines
b Objective Grid: Value-dependent cell outlining
b Objective Grid: Displaying double precision values in ODBC and ADO grids
b Objective Grid: Turning off header numbers and letters
b Objective Grid: Formatting a column of cells
b Objective Grid: Problem underlining blanks when printing
b Objective Grid: Sorting a combobox cell
b Objective Grid: Making a covered cell span an entire row
b Objective Grid: Resizing columns and rows without visible headers
b Objective Grid: Subclassing CGXTabBeam when the associated CGXTabWnd is embedded in a dialog
b Objective Grid: Having more than 32 items in CGXCheckListComboBox
b Objective Grid: Copying/Pasting cell formatting to/from Excel
b Objective Grid: Disabling message processing and user cancel operations
b Objective Grid: Always drawing the pushbutton in a combobox
b Objective Grid: Conditionally filling a combobox based on the contents of another cell
b Objective Grid: How do I display a grid with a Record Beam in a Form View?
b Objective Grid: Cell delete notification
b Objective Grid: Sending notifications to the parent dialog
b Objective Grid: Determining if the grid has focus
b Objective Grid: Embedding a grid in a CFormView
b Objective Grid: Drawing text in a combobox cell
b Objective Grid: Using the grid as a registered dialog control
b Objective Grid: Floating cells do not grow over the last frozen column
b Objective Grid: CGXComboBoxWnd draws over adjacent cells
b Objective Grid: Enabling listbox mode
b Objective Grid: OnEndEdit() called even when no editing has occurred
b Objective Grid: Creating a CGXMaskControl-derived control
b Objective Grid: Displaying international dates
b Objective Grid: Making changes to read-only cells
b Objective Grid: Determining the new row or column ID after a user drag
b Objective Grid: Implementing a virtual grid
b Objective Grid: Modifying the behavior of the tab key for a grid in a dialog
b Objective Grid: Adding a toolbar to a MDI child window with a CGXGridView
b Cell Attributes: Changing a read-only cell to be writable
b Objective Grid: Changing the font of header cells
b Objective Grid: Preventing user cancellation for CGXLongOperation
b Objective Grid: How can I insert and remove rows and columns at runtime?
b Objective Grid: Adding empty rows after the last record
b Objective Grid: Radio button/combobox click notification
b Objective Grid: Disabling colors for printing
b Objective Grid: Changing the mouse cursor when moving over cells
b Objective Grid: Resizing the client area of a grid to fit the width and height of the grid
b Objective Grid: International date style settings ignored
b Objective Grid: Bug in CGXUserAtttribute::IsEqual()
b Objective Grid: Writing a grid to a text file
b Objective Grid: Can I change the query for a grid at runtime?
b Objective Grid: Record set loading
b Objective Grid: Grid on a tab control vanishes
b Objective Grid: How can I turn off the message Automatic linking with .... at compilation time?
b Objective Grid: Determining the original row (or column) after a drag
b Objective Grid: Changing the appearance of a cell
b Objective Grid: Rows not resizing correctly
b Objective Grid: How can I create a 32-Bit extension DLL that uses Objective Grid?
b Objective Grid: How to fill a grid for best performance
b Objective Grid: Base styles
b Objective Grid: Setting colors for individual cells using palettes
b Objective Grid: Displaying default values in the last row
b Can I spread a title across two columns?
b Objective Grid: Converting an OLE move to a copy
b Objective Grid: Adding application-specific data
b Objective Grid: Copying parameter objects
b Objective Grid: Implementing a spin-list control
b Objective Grid: Placing images in a column header
b Objective Grid: Adding What's this? context-sensitive help to grid elements
b Objective Grid: Initializing an extension DLL
b How can I validate cell contents before they are stored in the grid?
b Objective Grid: Custom cell types
b Objective Grid: Displaying icons in cells
b Objective Grid: Printing with a zoom level
b Objective Grid: Frequent Automatic Linking with gx###.lib messages
b Objective Grid: How to keep the grid in synch with its recordset?
b Objective Grid: Tabbed combobox speed
b Objective Grid: Creating a CGXFont from a CFont
b Objective Grid: Problem with constructors being called before GXInit()
b Objective Grid: MFC integration
b Objective Grid: Handling OnKillFocus()
b Objective Grid: Retrieving the current text from a combobox
b Objective Grid: Pasting RichText into a grid
b Objective Grid: Pasting text without changing format
b Objective Grid: Outlining the current row with a border
b Objective Grid: Problems with the expression GetUserAttribute(IDS_MYATTRIBUTE)
b Objective Grid: Disable row and column moving
b Objective Grid: Setting the default size for a row or column
b Objective Grid: Grid types
b How to make the grid have no current cell
b Objective Grid: Using a grid in applications written in plain C
b Objective Grid: Text alignment changes during cell editing
b Objective Grid: Problems using the grid layout file created by Designer
b Objective Grid: Drawing rotated text in cells
b Objective Grid: Style change notifications
b Objective Grid: Determining the last filled row in a column
b Objective Grid: Deriving a grid class
b Objective Grid: Changing grid margins
b Objective Grid: Deactivating the current cell
b Objective Grid: Changing the outline frame for the current cell
b Objective Grid: Hiding headers
b Objective Grid: Setting the active cell characteristics
b Objective Grid: Preventing cell selection with the mouse
b Objective Grid: Hiding vertical header lines
b Cell Attributes: Determining the attributes of a cell
b Objective Grid: Using CGXPrintDevice with scroll views
b Objective Grid: Positioning the current cell
b Objective Grid: Preventing text display at the bottom of the screen
b Objective Grid: Handling combobox notifications
b Objective Grid: Disabling cells
b Objective Grid: How do I display a grid with a Record Beam in a dialog?
b Objective Grid: Using a tab control in a dialog
b Objective Grid: Moving the current cell to the first editable column in the selected row
b Objective Grid: Handling combobox notifications
b Objective Grid: Preventing the print setup dialog from appearing
b Objective Grid: Header cells not inverted when selected
b Objective Grid: Transactions with ODBC grids
b Objective Grid: Filling a combobox
b Objective Grid: Deferred binding to a recordset
b Objective Grid: Requerying the recordset does not reflect changes in the row count
b Objective Grid: Duplicate control IDs
b Objective Grid: How can I change the query for a grid at runtime?