Click here to Skip to main content
15,867,756 members
Articles / Desktop Programming / MFC
Tip/Trick

MFC Grid control 2.27 Compatibility with Grid Control 2.21

Rate me:
Please Sign up or sign in to vote.
5.00/5 (3 votes)
27 Mar 2013CPOL 18.7K   940   6   3
Minor changes on CGridCtrl 2.27 for compatibility with old version of this control

Introduction

This grid is the work of thousands of hours of squinting at pixels, hunting memory leaks, adding new features, fixing new bugs and beating the code by force of will into a form that is as feature rich and usable as something of this form can be. Dozens of developers from all over the world have contributed fixes, improvements and suggestions over the 4 years that the grid has been growing, and there is still no end in sight. Most of the fixes have been sent in by readers so I'm trusting that they have done sufficient testing. Please click for more information.

Release 2.27 is a minor update of 2.26 for Visual Studio 2010 and includes a couple of minor bug fixes. Version 2.26 is still available for download here, but at this release we lost AddPoint() method and m_strType at the version 2.21 of this control. I solve that problem with minor changes.

C++
 void BOOL CGridCtrl::AddPoint(CStringArray* ColStr,int row,int ColNo,int iImage)
{
	int col = 0;
	GV_ITEM Item;

	int r = GetRowCount();
	if(row >= r)
		SetRowCount(row+1);
	r = GetRowCount();

	for(col = 0 ; col < ColNo ; col++)
	{
		Item.mask = GVIF_TEXT;
		Item.row = row;
		Item.col = col;
		Item.crFgClr = RGB(255,0,0);  

		if(col == 0)
		{
			Item.iImage = iImage;
			Item.strText.Format("%d",row);
			Item.mask    |= (GVIF_FGCLR | GVIF_IMAGE);
		}
		else
		{
			Item.mask    |= (GVIF_FGCLR);
			Item.strText = ColStr->GetAt(col);
		}
		SetItem(&Item);
	}
	return true;
}
// 

Acknowledgement

  • Thanks to Chris Maunder

License

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


Written By
Software Developer (Senior) BHGE
Germany Germany
I worked as a software engineer and researcher in different countries with a wide range of related projects and engineers from all around the world. I was involved in Oil&Gas, Telecommunication, Transportation, and Semiconductor projects and played various roles such as junior, senior, and lead engineer both in embedded and non-embedded devices and technologies.

During my professional carrier, I was directly involved in designing and maintaining editor, compiler, and interpreter for IEC 611131-3 (PLC programming standard) and fault-tolerant communication layer for distributed automation standard IEC 61499, and many other projects such as DCS (Distributed Control Systems), (SCADA) Supervisory Control and Data Acquisition System, Oilfield (CMS) Computerised Maintenance Systems, Oil&Gas Laboratory Automaton Systems, and Semiconductor Equipment Connectivity Solutions.

Currently, I pursue a Ph.D. degree in Computer Science in the Technical University of Dresden and works as a software engineer in Germany. Beside, I am a certified specialist in Microsoft technologies since 2011.

My main research and work areas are Industrial Communication and Automation Systems, Real-Time Systems, Service-Oriented Systems, IEC 61131-3, IEC 61499, and Distributed Embedded Systems.

Comments and Discussions

 
QuestionWhat is this AddPoint method for? Pin
ehaerim17-Oct-13 10:51
ehaerim17-Oct-13 10:51 
AnswerRe: What is this AddPoint method for? Pin
Aydin Homay17-Oct-13 22:43
Aydin Homay17-Oct-13 22:43 
GeneralRe: What is this AddPoint method for? Pin
ehaerim18-Oct-13 0:52
ehaerim18-Oct-13 0:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.