Click here to Skip to main content
15,895,746 members
Articles / Desktop Programming / MFC

Multicolumn Combobox with Additional Format Conditions

Rate me:
Please Sign up or sign in to vote.
4.33/5 (2 votes)
9 May 2007CPOL2 min read 79K   5.3K   39  
Multicolumn Combobox with additional format conditions depending on the displayed values
#pragma once

class CMCColumn : public CObject
{
public:
	DECLARE_DYNAMIC(CMCColumn)

	enum	ColumnAlignment
	{
		CA_AlignmentLeft			= 1,
		CA_AlignmentCenter,
		CA_AlignmentRight
	};

							 CMCColumn					( int nColumnIndex, CMCColumn::ColumnAlignment eColumnAlignment = CMCColumn::CA_AlignmentLeft );

	virtual					~CMCColumn					( );

			//	returns the column index - is needed as reference in the format condition
			int				 Get_ColumnIndex			( void );
			//	returns the format definition used by CDC::DrawText()
			UINT			 Get_DrawTextFormatValue	( void );


			//	returns the static width of the column
			int				 Get_StaticWidth			( void );
			//	sets the static width of the column
			void			 Set_StaticWidth			( int nStaticWidth );

			//	returns the calculated width of the column
			int				 Get_AutoSizeWidth			( void );
			//	sets the calculated width of the column
			void			 Set_AutoSizeWidth			( int nAutoSizeWidth );

			//	returns true if the column is dynamic -> its width is calculated based on the content
			bool			 Get_DynamicWidth			( void );
			//	true  -> the column width is calculated on the base of its content
			//	false -> the static width value is used.
			void			 Set_DynamicWidth			( bool bDynamicWidth );

			//	returns the static resp. calculated with depending on the fact if the column is defined as dynamic column or not
			int				 Get_Width					( void );

			//	returns if a column seperator on the left side of the column is drawn or not
			bool			 Get_DrawSeparator			( void );
			//	true  -> column seperator is drawn
			//	false -> no column seperator
			void			 Set_DrawSeparator			( bool bDrawSeparator );

private:
	int						 m_nColumnIndex;
	ColumnAlignment			 m_eColumnAlignment;
	int						 m_nStaticWidth;
	int						 m_nAutoSizeWidth;
	bool					 m_bDrawSeparator;
	bool					 m_bDynamicWidth;
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Germany Germany
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions