Board index » delphi » What is the best solution

What is the best solution

I have the following requirement: I want to show the user a list from which
he can make a choice. The list is made up of rows with 3 different data like
the following:
Jan-Feb     100   1000
Mar-Apr    200   1500
............      ......   .......

The first row of the list should contain a choice that would trigger to
build and present a different list .
Additionally, if this is possible, I would like the user to be able to
modify the list or to add to it (at a specific index of the list).

I tried:
1 ComboBox:
   It is not ideal, since I would like to show the user most if not all the
items of the list (max 12 items). I used an Arial font to setup the row so
that every item is correctly aligned. It is easy to add a new Item using the
edit but I did not find a way to add it at a specific position.
2 ListBox:
   The trick of setting up a row with different items aligned using blanks
and using Arial surprisingly doesn't work (unlsee I made some mistake).
Adding additional items it is not as easy and I did not find how to add it
where the user wants.

I imagine this is not a particularly strange requirements. Is it possible
there isn't anything ideal for this ? Do you know better than I do ? Thanks

 

Re:What is the best solution


"Franco Jommi" <franco.jom...@tin.it> skrev i melding
news:MVCda.75217$pG1.1732290@news1.tin.it...

Quote
> I have the following requirement: I want to show the user a list from
which
> he can make a choice. The list is made up of rows with 3 different data
like
> the following:
> Jan-Feb     100   1000
> Mar-Apr    200   1500
> ............      ......   .......

> The first row of the list should contain a choice that would trigger to
> build and present a different list .
> Additionally, if this is possible, I would like the user to be able to
> modify the list or to add to it (at a specific index of the list).

> I tried:
> 1 ComboBox:
>    It is not ideal, since I would like to show the user most if not all
the
> items of the list (max 12 items). I used an Arial font to setup the row so
> that every item is correctly aligned. It is easy to add a new Item using
the
> edit but I did not find a way to add it at a specific position.
> 2 ListBox:
>    The trick of setting up a row with different items aligned using blanks
> and using Arial surprisingly doesn't work (unlsee I made some mistake).
> Adding additional items it is not as easy and I did not find how to add it
> where the user wants.

A TStringGrid (or better - an enhanced 3rd party descendant) should be ideal
for the job, as it has both columns and Insert/edit functionality. You may
also laod data directly into the grid using CommaText property.

  Rows[i].CommaText:=TextLine;

--
Regards,

Bj?rge S?ther
bjorge@haha_itte.no

Re:What is the best solution


Quote
Franco Jommi wrote:
> I have the following requirement: I want to show the user a list from which
> he can make a choice. The list is made up of rows with 3 different data like
> the following:
> Jan-Feb     100   1000
> Mar-Apr    200   1500
> ............      ......   .......

> The first row of the list should contain a choice that would trigger to
> build and present a different list .
> Additionally, if this is possible, I would like the user to be able to
> modify the list or to add to it (at a specific index of the list).

Have you tried using a grid?

--
Cheers,
Phillip Flores
"Track your time...Use VeriTime"
http://www.pcfworks.com

Re:What is the best solution


I had thought to a TStringGrid, but it looked somewhat too complicated for a
problem that sounded rather "standard". But may be that is because I am not
used to a TStringGrid. I will try to have a look into it, thanks. But what
you precisely mean by loading data directly into the grid using CommaText
property? I peek the 3 elements of my list row from fields in a record.

"Bj?rge S?ther" <bjorge@hahaha_itte.no> ha scritto nel messaggio
news:ueDda.40900$Rc7.592075@news2.e.nsc.no...

Quote
> "Franco Jommi" <franco.jom...@tin.it> skrev i melding
> news:MVCda.75217$pG1.1732290@news1.tin.it...
> > I have the following requirement: I want to show the user a list from
> which
> > he can make a choice. The list is made up of rows with 3 different data
> like
> > the following:
> > Jan-Feb     100   1000
> > Mar-Apr    200   1500
> > ............      ......   .......

> > The first row of the list should contain a choice that would trigger to
> > build and present a different list .
> > Additionally, if this is possible, I would like the user to be able to
> > modify the list or to add to it (at a specific index of the list).

> > I tried:
> > 1 ComboBox:
> >    It is not ideal, since I would like to show the user most if not all
> the
> > items of the list (max 12 items). I used an Arial font to setup the row
so
> > that every item is correctly aligned. It is easy to add a new Item using
> the
> > edit but I did not find a way to add it at a specific position.
> > 2 ListBox:
> >    The trick of setting up a row with different items aligned using
blanks
> > and using Arial surprisingly doesn't work (unlsee I made some mistake).
> > Adding additional items it is not as easy and I did not find how to add
it
> > where the user wants.

> A TStringGrid (or better - an enhanced 3rd party descendant) should be
ideal
> for the job, as it has both columns and Insert/edit functionality. You may
> also laod data directly into the grid using CommaText property.

>   Rows[i].CommaText:=TextLine;

> --
> Regards,

> Bj?rge S?ther
> bjorge@haha_itte.no

Re:What is the best solution


In article <N7Lda.111627$zo2.2933...@news2.tin.it>, "Franco Jommi"

Quote
<franco.jom...@tin.it> writes:
>I had thought to a TStringGrid, but it looked somewhat too complicated

If you're looking to decide which column of a stringgrid was clicked, there is
a simple technique which overcomes the problem of not getting the mouse cell in
the OnClick or OnDoubleClick handler. This stores the mouse X & Y in a global
variable in OnMouseDown, then accesses those in the OnDoubleClick event handler
and uses MouseToCell. This relies on the fact that a mouse-down notification is
always sent before a click or double-click notification. The code is as follows
...

var
  MouseX, MouseY : integer;

procedure TForm1.StringGrid1MouseDown(Sender: TObject;
         Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  {store mouse X & Y}
  MouseX := X;
  MouseY := Y;
end;

procedure TForm1.StringGrid1DblClick(Sender: TObject);
var
  ACol, ARow : integer;
begin
  {calculate cell}
  StringGrid1.MouseToCell(MouseX, MouseY, ACol, ARow);
  {test for menu row}
  if ARow = 1 then
    ShowMessage('You Dbl-Clicked Column ' + IntToStr(ACol));
end;

Alan Loyd
alangll...@aol.com

Re:What is the best solution


Thanks. I am going to experiment.

"AlanGLLoyd" <alangll...@aol.com> ha scritto nel messaggio
news:20030318160413.29016.00000880@mb-fy.aol.com...

Quote
> In article <N7Lda.111627$zo2.2933...@news2.tin.it>, "Franco Jommi"
> <franco.jom...@tin.it> writes:

> >I had thought to a TStringGrid, but it looked somewhat too complicated

> If you're looking to decide which column of a stringgrid was clicked,
there is
> a simple technique which overcomes the problem of not getting the mouse
cell in
> the OnClick or OnDoubleClick handler. This stores the mouse X & Y in a
global
> variable in OnMouseDown, then accesses those in the OnDoubleClick event
handler
> and uses MouseToCell. This relies on the fact that a mouse-down
notification is
> always sent before a click or double-click notification. The code is as
follows
> ...

> var
>   MouseX, MouseY : integer;

> procedure TForm1.StringGrid1MouseDown(Sender: TObject;
>          Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
> begin
>   {store mouse X & Y}
>   MouseX := X;
>   MouseY := Y;
> end;

> procedure TForm1.StringGrid1DblClick(Sender: TObject);
> var
>   ACol, ARow : integer;
> begin
>   {calculate cell}
>   StringGrid1.MouseToCell(MouseX, MouseY, ACol, ARow);
>   {test for menu row}
>   if ARow = 1 then
>     ShowMessage('You Dbl-Clicked Column ' + IntToStr(ACol));
> end;

> Alan Loyd
> alangll...@aol.com

Re:What is the best solution


Quote
"Franco Jommi" <franco.jom...@tin.it> wrote in message

news:MVCda.75217$pG1.1732290@news1.tin.it...

Quote
> I have the following requirement: I want to show the user a list from
which
> he can make a choice. The list is made up of rows with 3 different data
like
> the following:
> Jan-Feb     100   1000
> Mar-Apr    200   1500
> ............      ......   .......

> The first row of the list should contain a choice that would trigger to
> build and present a different list .
> Additionally, if this is possible, I would like the user to be able to
> modify the list or to add to it (at a specific index of the list).
> 2 ListBox:
>    The trick of setting up a row with different items aligned using blanks
> and using Arial surprisingly doesn't work (unlsee I made some mistake).
> Adding additional items it is not as easy and I did not find how to add it
> where the user wants.

Have you tried using tabs with a listbox or tCheckListBox? Another option
would be to make the list box OwnerDraw.

You might also want to investigate tVirtualTree
(http://www.lischke-online.de/VirtualTreeview/VT.php). Its the string tree
descendant is relatively easy to use, supports check boxes and multiple
columns.

Re:What is the best solution


Yes, tabs looks good enough. Still I wonder why characters don't get aligned
using non proportional fonts ...

"Bruce Roberts" <b...@bounceitattcanada.xnet> ha scritto nel messaggio
news:4v1ea.1364$DA4.171520@news20.bellglobal.com...

Quote

> "Franco Jommi" <franco.jom...@tin.it> wrote in message
> news:MVCda.75217$pG1.1732290@news1.tin.it...
> > I have the following requirement: I want to show the user a list from
> which
> > he can make a choice. The list is made up of rows with 3 different data
> like
> > the following:
> > Jan-Feb     100   1000
> > Mar-Apr    200   1500
> > ............      ......   .......

> > The first row of the list should contain a choice that would trigger to
> > build and present a different list .
> > Additionally, if this is possible, I would like the user to be able to
> > modify the list or to add to it (at a specific index of the list).

> > 2 ListBox:
> >    The trick of setting up a row with different items aligned using
blanks
> > and using Arial surprisingly doesn't work (unlsee I made some mistake).
> > Adding additional items it is not as easy and I did not find how to add
it
> > where the user wants.

> Have you tried using tabs with a listbox or tCheckListBox? Another option
> would be to make the list box OwnerDraw.

> You might also want to investigate tVirtualTree
> (http://www.lischke-online.de/VirtualTreeview/VT.php). Its the string tree
> descendant is relatively easy to use, supports check boxes and multiple
> columns.

Re:What is the best solution


On Thu, 20 Mar 2003 18:00:57 GMT, "Franco Jommi"

Quote
<franco.jom...@tin.it> wrote:
>Yes, tabs looks good enough. Still I wonder why characters don't get aligned
>using non proportional fonts ...

I may be missing the point, but it is possible to align stuff in
Listboxes using #9 to position the columns

One can either use the TabWidth property

or: LB_SETTABSTOPS

Even proportional fonts assume a fixed width for numbers,
IIRC  twice the width of #32 or '.'

Other Threads