Discussion:
TValueListEditor
(too old to reply)
unknown
2003-11-25 11:39:50 UTC
Permalink
hi,

i need a component quite similar to TValueListEditor but with a
dropdown combobox for the values (and if possible 3 columns):

.--------------------------------------------.
| Column 1 | Column 2 | Column 3 |
|--------------------------------------------|
| ... | ... | ... \/ |
|--------------------------------------------|
| ... | ... | ... \/ |
'--------------------------------------------'

plz do not tell me about virtual tree, it is toooo big and doesn't
work perfectly for me (and the author never replies to my
questions)!:-/

thanks a lot,
Rob
Alexander Nagumanov
2003-11-25 14:07:24 UTC
Permalink
Post by unknown
i need a component quite similar to TValueListEditor but with a
.--------------------------------------------.
| Column 1 | Column 2 | Column 3 |
|--------------------------------------------|
| ... | ... | ... \/ |
|--------------------------------------------|
| ... | ... | ... \/ |
'--------------------------------------------'
plz do not tell me about virtual tree, it is toooo big and doesn't
work perfectly for me (and the author never replies to my
questions)!:-/
TStringGrid, TDrawGrid, TListView.
unknown
2003-11-26 07:05:56 UTC
Permalink
Post by Alexander Nagumanov
Post by unknown
i need a component quite similar to TValueListEditor but with a
TStringGrid, TDrawGrid, TListView.
i like TStringGrid. it is my favorite grid component, but can
you please tell me how i can add a drop-down combobox to a
string grid?

thnx,
Rob
Alexander Nagumanov
2003-11-26 08:21:14 UTC
Permalink
Post by unknown
i like TStringGrid. it is my favorite grid component, but can
you please tell me how i can add a drop-down combobox to a
string grid?
Well, see source code TValueListEditor
unknown
2003-11-26 10:39:26 UTC
Permalink
Post by Alexander Nagumanov
Well, see source code TValueListEditor
thanks for your replies, but i'm completely unfamiliar with
writing VCLs. i will be so glad if i could find a component
actually as same as TValueListEditor but with 3 columns and
a drop-down combobox as the value editor (as i described well
in my first post).

Rob
Alexander Nagumanov
2003-11-26 13:22:05 UTC
Permalink
Post by unknown
thanks for your replies, but i'm completely unfamiliar with
writing VCLs. i will be so glad if i could find a component
actually as same as TValueListEditor but with 3 columns and
a drop-down combobox as the value editor (as i described well
in my first post).
Maybe this helps?
============================================
From: "Peter Below (TeamB)"
Subject: Re: TListView Question : Embedding a TCombobox?
Post by unknown
Has anyone figured out how to have a TCombobox embedded in one or more of
the TListview's SubItems?
Attach a combobox to a listview subitem column and scoll them with
the listview.

You have to trap scroll messages to the listview and update the
comboboxes position. See example below. The listview has three columns,
width set to -1 for all three.

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Forms,
Dialogs, stdctrls, ComCtrls;

type

TForm1 = class(TForm)
Button1: TButton;
ListView1: TListView;
ComboBox1: TComboBox;
Memo1: TMemo;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
FOldListviewWindowProc: TWndMethod;
FListviewHeaderHeight: Integer;
Procedure ListviewWindowproc(var Message: TMessage);
procedure AttachCombobox;
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation
uses commctrl;

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
i: integer;
r: TRect;
ListviewHeader: HWND;
begin
for i:= 1 to 10 do
with listview1.Items.add do begin
caption := format('Item %d',[i]);
subitems.add( format('SubItem %d.1',[i]) );
subitems.add( format('SubItem %d.2',[i]) );
end;
ListviewHeader := GetWindow( listview1.Handle, GW_CHILD );
GetWIndowrect( ListviewHeader, r );
FListviewHeaderHeight := r.Bottom - r.top;

FOldListviewWindowProc:= listview1.WindowProc;
listview1.WindowProc := ListviewWindowproc;
AttachCombobox;
end;

procedure TForm1.AttachCombobox;
var
r: TRect;
wnd: HWND;
begin
fillchar( r, sizeof(r), 0 );
ListView_GetSubItemRect( listview1.Handle, 4, 1, LVIR_BOUNDS, @r );
combobox1.Parent := listview1;
combobox1.BoundsRect := r;
combobox1.Visible := r.Top >= FListviewHeaderHeight;
end;

procedure TForm1.ListviewWindowproc(var Message: TMessage);
begin
FOldListviewWindowProc( Message );
Case Message.Msg Of
WM_VSCROLL, WM_HSCROLL:
If Message.WParamLo <> SB_ENDSCROLL Then
AttachCombobox;
End;
end;

end.

--
Peter Below (TeamB)
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be
unknown
2003-11-26 21:00:56 UTC
Permalink
Post by Alexander Nagumanov
Maybe this helps?
============================================
From: "Peter Below (TeamB)"
Subject: Re: TListView Question : Embedding a TCombobox?
...
thanks a lot to you and Peter Below,

but there are 3 problems in this code:

1. if the listview has xp style headers, the FListViewHeaderHeight
won't have the valid value, so it never shows the combo box for
the first visible line.

2. the listview column height is not similar to the height of the
combobox. so it has a strange behavior. how to set the height
of combobox or listview to the height of the other one.

3. to be able to show the combobox whenever the user selects a
row, we should call AttachCombobox inside the OnSelect handler
of the listview as below:

procedure TForm1.AttachCombobox(Index: Integer);
...
begin
...
ListView_GetSubItemRect( listview1.Handle, Index, 1, LVIR_BOUNDS, @r );
...
end;

procedure TForm1.ListviewWindowproc(var Message: TMessage);
begin
...
If Message.WParamLo <> SB_ENDSCROLL Then
AttachCombobox( listview1.Selected.Index );
end;

procedure TForm1.ListviewOnSelect(...);
begin
AttachCombobox(Item.Index);
end;

but in that case, when the user uses arrow keys to move through
lines and it scrolls down, the combobox will be displayed for the
line after the selected one. IMHO it is because AttachCombobox is
called twice.

thanks for any reply,
Rob

Loading...