Strange behavior when trying to SetCaption |
Post Reply |
Author | |
dennisV
Senior Member Joined: 07 October 2004 Location: Australia Status: Offline Points: 242 |
Post Options
Thanks(0)
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) |
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
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(""));} |
|
dennisV
Senior Member Joined: 07 October 2004 Location: Australia Status: Offline Points: 242 |
Post Options
Thanks(0)
|
SetValue (with casting to *text) seems to do the trick!
Thanks, Dennis |
|
// W7 64 Ultimate SP1
// VS 2008 // CodeJock 16.2.3 (MFC) |
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
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!
|
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |