Print Page | Close Window

Strange behavior when trying to SetCaption

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Report Control
Forum Description: Topics Related to Codejock Report Control
URL: http://forum.codejock.com/forum_posts.asp?TID=15024
Printed Date: 29 September 2024 at 3:32pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Strange behavior when trying to SetCaption
Posted By: dennisV
Subject: Strange behavior when trying to SetCaption
Date Posted: 21 August 2009 at 10:38pm
Hello,

I'm observing strange behavior - I populate my records as normal, then one record is changed and I use:

pRecord->GetItem(9)->SetCaption(strCaption);

to update the displayed text, which does that in all cases, except:

If GetItem(9) was not an empty string when Populate() was called and I then try to set it with an empty string, it reverts back to the original non-empty value. So, let's say it was "abc" initially, then I call SetCaption(""), it displays "abc".

Also, I can change it to "def", it displays "def", then I set it to "" and it displays "abc" again.

Weird Am I doing something wrong or is there  a bug in the control?

Thanks,

Dennis


-------------
// W7 64 Ultimate SP1
// VS 2008
// CodeJock 16.2.3 (MFC)



Replies:
Posted By: mdoubson
Date Posted: 22 August 2009 at 2:06am
Check your item type - (CXTPReportRecordItem or CXTPReportRecordItemText or other derived types)
Compare 2 cases on initialization

1 - AddItem(new CXTPReportRecordItemText("ABC")); // this case will not allow empty string to set as caption because "ABC" will be default value.

2 - AddItem(new CXTPReportRecordItemText())->SetCaption("ABC"); //this case will allow empty string to set as caption as default value now - empty string
 
btw - you can use more simple function: GetReportCtrl().SetCellText(Row#, Col#, Text);
 
CXTPReportRecordItemText::CXTPReportRecordItemText(LPCTSTR szText) : CXTPReportRecordItem(), m_strText(szText) { }

 CString CXTPReportRecordItemText::GetCaption(CXTPReportColumn* /*pColumn*/) {

if (!m_strCaption.IsEmpty()) return m_strCaption;

if (m_strFormatString == _T("%s")) return m_strText;

CString strCaption;

strCaption.Format(m_strFormatString, (LPCTSTR)m_strText);

return strCaption;

}

void CXTPReportRecordItemText::OnEditChanged(XTP_REPORTRECORDITEM_ARGS* pItemArgs, LPCTSTR szText) {

SetValue(szText);

CXTPReportRecordItem::OnEditChanged(pItemArgs, szText);

}

void CXTPReportRecordItemText::DoPropExchange(CXTPPropExchange* pPX) {

CXTPReportRecordItem::DoPropExchange(pPX);

PX_String(pPX, _T("Text"), m_strText, _T(""));

}



-------------
Mark Doubson, Ph.D.


Posted By: dennisV
Date Posted: 22 August 2009 at 4:23am
SetValue (with casting to *text) seems to do the trick!

Thanks,

Dennis


-------------
// W7 64 Ultimate SP1
// VS 2008
// CodeJock 16.2.3 (MFC)


Posted By: mdoubson
Date Posted: 22 August 2009 at 10:20am
CXTPReportRecordItemText allow to use in-place-edit control with validation and user choice to escape in any point including one - select content - (Ctrl+A) - cut it (Ctrl+C) - escape - and Core should restore old value!

-------------
Mark Doubson, Ph.D.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net