Perhaps I need to do a little more clarification here. I do not need to format a date string. I need to et the control so that it formats the date string. The Win32::GUI::DateTime control, which is what I suspect Grid is using, can be set to use different dat/time format via the Format method. I just don't know how to access the DateTime object within the Grid Cell object so that it displays the correct format. Here is a short piece of code to demonstrate the issue:
#!c:\perl\wperl.exe
use strict;
use Win32::GUI;
use Win32::GUI::Grid;
my $mainform = Win32::GUI::Window->new(-name=>'main',-text=>'Grid Date
+ Format Problem',-width=>810,-height=>625,-dialogui=>1);
my $grid = $mainform->AddGrid(-name=>'grid',-pos=>[25,85],-rows=>2,-co
+lumns=>3,-fixedrows=>1,-fixedcolumns=>1,-editable=>1,-size=> [520,400
+],-addstyle=>WS_VSCROLL|WS_TABSTOP);
$grid->SetColumnWidth(0,100);
$grid->SetColumnWidth(1,100);
$grid->SetColumnWidth(2,100);
$grid->SetRowHeight(1,30);
$grid->SetCellText(0, 0, "ID");
$grid->SetCellText(0, 1, "GVIT_DATECAL");
$grid->SetCellText(0, 2, "GVIT_DATE");
$grid->SetCellFormat(1, 1, 'yyyy-MM-dd');
$grid->SetCellType(1, 1, GVIT_DATECAL);
$grid->SetCellText(1, 1, "2005-07-19");
$grid->SetCellFormat(1, 2, 'yyyy-MM-dd');
$grid->SetCellType(1, 2, GVIT_DATE);
$grid->SetCellText(1, 2, "2005-07-19");
$mainform->Show();
Win32::GUI::Dialog();
The
SetCellFormat method is probably not what I need to use here but I have no idea how to make it work. After you select a date using the control, the cell will display the date in whatever your short date format is. If you change your short date format and re-run the program, it will display in the new format you set. I want to ignore the default setting for the system and set the format myself.
By the way, the code you provided doesn't work as far as I can tell. Whether I send it a date like 2005/7/19 or 7/19/2005 it returns something that doesn't look like a date to me.
But again, thanks for replying.
Chris
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.