Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Report Control
  New Posts New Posts RSS Feed - Strange behavior when trying to SetCaption
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Strange behavior when trying to SetCaption

 Post Reply Post Reply
Author
Message
dennisV View Drop Down
Senior Member
Senior Member
Avatar

Joined: 07 October 2004
Location: Australia
Status: Offline
Points: 242
Post Options Post Options   Thanks (0) Thanks(0)   Quote dennisV Quote  Post ReplyReply Direct Link To This Post Topic: Strange behavior when trying to SetCaption
    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)
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post 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(""));

}

Back to Top
dennisV View Drop Down
Senior Member
Senior Member
Avatar

Joined: 07 October 2004
Location: Australia
Status: Offline
Points: 242
Post Options Post Options   Thanks (0) Thanks(0)   Quote dennisV Quote  Post ReplyReply Direct Link To This Post 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)
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post 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!
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.188 seconds.