Click here to Skip to main content
15,911,786 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to learn to use the wxCalendarCtrl, to simply place a selected date in a text control. (using CodeBlocks & wxWidgets)

The wxCalendarCtrl Class Reference isn't enough help for me. Not finding any examples or tutorials. Even the CodeProject wxWidget article & examples fails to include the wxCalendarCtrl.

My partial code: //with No matching function call error

C++
void wxPanel4Frame::OnbtnBeginClick(wxCommandEvent& event)
    {
    txtBdate->SetValue(CalendarCtrl1->GetDate());
    }


btnBeginDate: Button
txtBdate: text control var
C++
#include <wx/calctrl.h>  // included


Any help appreciated.
Posted
Updated 18-Mar-15 11:02am
v2

no idea - never used it - but i;m guessing you're trying to get the string representation of the time?

from the docs, GetDate returns a wxDateTime, that exposes a method FormatTime, that returns a wxString, that has a member c_str() that gives you a string

so you want something like

<br />
void wxPanel4Frame::OnbtnBeginClick(wxCommandEvent& event)<br />
{<br />
    txtBdate->SetValue(CalendarCtrl1->GetDate().FormatTime(...).c_str());<br />
}<br />
 
Share this answer
 
Comments
EdwardX2 18-Mar-15 18:26pm    
Looking for a date like: 03/18/2015.
So I'll try something like:

void wxPanel4Frame::OnbtnBeginClick(wxCommandEvent& event)
{
txtBdate->SetValue(CalendarCtrl1->GetDate().FormatDate("mm/dd/yyyy").c_str());
// But txtBdate can't be in the above line then
}
barneyman 18-Mar-15 19:45pm    
i either don't understand the comment about txtBdate or i've completely misunderstood your initial problem :)
This retrieves the date selected from the wxCalendarCtrl.

C++
txtBdate->SetValue(CalendarCtrl1->GetDate().FormatDate());
 
Share this answer
 
v3

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900