 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Robin Dobos Guest
|
Posted: Mon Feb 09, 2004 10:48 pm Post subject: spinedit for month |
|
|
Dear all
I am trying to put together an interface that requires users to select
a month of the year. They are not keen on a dropdown list combobox or
a calendar, but would prefer a "spinedit" type selection.
I have tried updown and spinedit but see that they are meant for
integer values. Does anyone know of a component that handles text in a
similar way?
MTIA :-)
Robin
|
|
| Back to top |
|
 |
Dan Guest
|
Posted: Tue Feb 10, 2004 1:14 am Post subject: Re: spinedit for month |
|
|
On 9 Feb 2004 14:48:15 -0800, [email]robin.dobos (AT) agric (DOT) nsw.gov.au[/email] (Robin
Dobos) wrote:
| Quote: | Dear all
I am trying to put together an interface that requires users to select
a month of the year. They are not keen on a dropdown list combobox or
a calendar, but would prefer a "spinedit" type selection.
I have tried updown and spinedit but see that they are meant for
integer values. Does anyone know of a component that handles text in a
similar way?
MTIA :-)
Robin
|
You should be able to use UP/DN buttons and a TEdit. Create a list
(see TStrings) of month names (or an array of month names and numbers,
if you will need the number of the month rather than the name). Then
in the OnUpClick and OnDownClick events for the spinbuttons, put code
to step through the list or array to display the month name in the
edit box. You will need to test for end of list and wrap around to the
other end, if you want it do that, or put in code to keep from running
off the end and doing who knows what ;-)
I use this method and have no problems making it do just what I want.
HTH,
Dan
|
|
| Back to top |
|
 |
Dan Guest
|
Posted: Tue Feb 10, 2004 4:59 pm Post subject: Re: spinedit for month |
|
|
On Mon, 09 Feb 2004 18:14:27 -0700, Dan <Doculus at CMDCsystems dot
com> wrote:
| Quote: |
You should be able to use UP/DN buttons and a TEdit. Create a list
(see TStrings) of month names (or an array of month names and numbers,
if you will need the number of the month rather than the name). Then
in the OnUpClick and OnDownClick events for the spinbuttons, put code
to step through the list or array to display the month name in the
edit box. You will need to test for end of list and wrap around to the
other end, if you want it do that, or put in code to keep from running
off the end and doing who knows what ;-)
I use this method and have no problems making it do just what I want.
HTH,
Dan
This is a bit misleading. I looked up what I had done, and it was |
using TSpinButton, not the TUpDown control, which doesn't have
separate events for the two buttons. The following code will work with
the TUpDown buttons. Note that the number returned by the Position
property of the control is zero based to correspond to the zero based
StringList.
procedure TfrmOpen.Edit1Click(Sender: TObject);
begin
monthlist := TStringList.Create;
monthlist.CommaText :=
'Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec';
// use whatever string values here: language, length...
Edit1.Text := monthlist[0]; // default to Jan
end;
procedure TfrmOpen.UpDown1Click(Sender: TObject; Button: TUDBtnType);
begin
Edit1.Text := monthlist.Strings[UpDown1.position];
end;
Leave Associate prop blank.
If Wrap is true, list will go from Dec to Jan on an upclick.
HTH,
Dan
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|