Autor Beitrag
Chatfix
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1583
Erhaltene Danke: 10

Win 10, Win 8, Win 7, Win Vista, Win XP
VB.net (VS 2015), MsSQL (T-SQL), HTML, CSS, PHP, MySQL
BeitragVerfasst: Sa 03.04.04 13:01 
Mich beschäftigt zur Zeit ein Problem für das ich keine Lösung habe...

Folgendes: ich habe ein ListView (Entwicklungszeit).

In diesem werden Dateien von mir verwaltet.
Die Dateien werden beim start eingelesen und es wird der im Header befindliche "Kategorie"-Teil ausgelesen.
Nun wollte ich immer wenn eine neue Kategorie gefunden wurde einen Tab machen, und auf diesem ein ListView erstellen, der komplett ALLE eigenschaften und Ereignisse hat wie das ListView das ich zur Entwicklungszeit angelegt habe.

Der erste ListView von der Entwicklungszeit ist immer, weil dieser alle Dateien auflisten sollen, und dann die weiteren Tabs um die einzelnen Kategorien auszuwählen.

Ich hoffe ihr versteht was ich meine.

Danke schonmal im vorraus!

_________________
Gehirn: ein Organ, mit dem wir denken, daß wir denken. - Ambrose Bierce
catweasel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 487
Erhaltene Danke: 1

Win 7 64bit
Delphi 7 Second Sedition V7.2
BeitragVerfasst: Sa 03.04.04 13:15 
Naja, erstelle einen neuen ListView Typ mit allen Eigenschaften die du so brauchst und weis alle nötigen Ereignisse zu...
Da kannst du beliebig viele von erstellen die alle "gleich" sind......
Und dann erstellst du eben auch den ersten Listview zur Laufzeit....

Catweasel

_________________
Pommes werden schneller fertig wenn man sie vor dem Frittieren einige Minuten in siedendes Fett legt.
Chatfix Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1583
Erhaltene Danke: 10

Win 10, Win 8, Win 7, Win Vista, Win XP
VB.net (VS 2015), MsSQL (T-SQL), HTML, CSS, PHP, MySQL
BeitragVerfasst: Sa 03.04.04 13:24 
Kannst du mal bitte ein Beispiel posten, mit einer Eigenschaft, und einem ereignis?

_________________
Gehirn: ein Organ, mit dem wir denken, daß wir denken. - Ambrose Bierce
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Mo 05.04.04 15:29 
Hallo!

Wo hakt es denn genau?

MfG
Peter

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Chatfix Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1583
Erhaltene Danke: 10

Win 10, Win 8, Win 7, Win Vista, Win XP
VB.net (VS 2015), MsSQL (T-SQL), HTML, CSS, PHP, MySQL
BeitragVerfasst: Mo 05.04.04 15:32 
Nunja, die Lösung von Catweasel gefällt mir ganz gut, nur habe ich noch nie eine Komponente als neuen Typ angelgt, deswegen habe ich nach einem Beispiel gefragt, mit einer Eigenschaft und einem Ereignis... den Rest dürfte ich dann schon hinbekommen...

_________________
Gehirn: ein Organ, mit dem wir denken, daß wir denken. - Ambrose Bierce
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Mo 05.04.04 15:40 
Okay. Folgendes erstellt einen neuen Button zur Laufzeit mit einem OnClick-Ereignis:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
type
  TmyButton = class(TButton)
    procedure Button2Click(Sender: TObject);
  private
  public
    constructor create(AOwner : TComponent);
end;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);


  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

constructor TmyButton.create(AOwner : TComponent);
begin
  inherited;
  self.width := 150;
  self.height := 150;
  self.Caption := 'identischer Button';
  self.OnClick := self.Button2CLick;
end;

procedure TmyButton.Button2Click(Sender: TObject);
begin
  ShowMessage('Click');
end;

procedure TForm1.Button1Click(Sender: TObject);
var myButton : TmyButton;
begin
  myButton := TmyButton.Create(self);
  myButton.Parent := Form1;
end;

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Chatfix Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1583
Erhaltene Danke: 10

Win 10, Win 8, Win 7, Win Vista, Win XP
VB.net (VS 2015), MsSQL (T-SQL), HTML, CSS, PHP, MySQL
BeitragVerfasst: Mo 05.04.04 15:43 
Wenn ich jetzt mehrere Buttons erstelle, kann ich dann hier

ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TmyButton.Button2Click(Sender: TObject); 
begin 
  ShowMessage('Click'); 
end;


auch rausbekommen, welcher button das ereignis ausgelöst hat?

_________________
Gehirn: ein Organ, mit dem wir denken, daß wir denken. - Ambrose Bierce
maximus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 896

Win XP, Suse 8.1
Delphi 4/7/8 alles prof
BeitragVerfasst: Mo 05.04.04 15:49 
Ja...dafür ist der sender da!

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TmyButton.Button2Click(Sender: TObject); 
begin 
  ShowMessage(TComponent(Sender).name+'Click'); 
  // ...
  if sender = Button2 then ...
  else
  if sender = Button3 then ...;
end;

_________________
mfg.
mâximôv
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Mo 05.04.04 15:49 
Ja.. einfach über den Parameter Sender..! Sender ist immer eine Referenz zum aufrufenden Objekt...!

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
Chatfix Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1583
Erhaltene Danke: 10

Win 10, Win 8, Win 7, Win Vista, Win XP
VB.net (VS 2015), MsSQL (T-SQL), HTML, CSS, PHP, MySQL
BeitragVerfasst: Mo 05.04.04 15:53 
OK danke, werde das nachher zuhause gleich mal probieren :)

Vielen Dank nochmal, und sorry fürs schieben...

_________________
Gehirn: ein Organ, mit dem wir denken, daß wir denken. - Ambrose Bierce
Chatfix Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1583
Erhaltene Danke: 10

Win 10, Win 8, Win 7, Win Vista, Win XP
VB.net (VS 2015), MsSQL (T-SQL), HTML, CSS, PHP, MySQL
BeitragVerfasst: Mo 05.04.04 19:00 
Es funktioniert soweit ganz gut, hab nur noch ein problem...

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
type
  TBlahList = class(TListView)
    private
    public
      constructor create(AOwner: TComponent);
    end;

constructor TBlahList.create(AOwner : TComponent);
var
  i: Integer;
begin
  inherited;
  Self.Parent := Form1.TabSheet2;
  Self.Align := Form1.ListView1.Align;
  //Self.Columns := Form1.ListView1.Columns;
  Self.OnInfoTip := Form1.ListView1InfoTip;
  for i := 0 to Form1.ListView1.Columns.Count - 1 do
  begin
    Self.Columns.Add;
    Self.Columns.Items[i].Alignment := Form1.ListView1.Columns.Items[i].Alignment;
    Self.Columns.Items[i].AutoSize := Form1.ListView1.Columns.Items[i].AutoSize;
    Self.Columns.Items[i].Caption := Form1.ListView1.Columns.Items[i].Caption;
    Self.Columns.Items[i].Width := Form1.ListView1.Columns.Items[i].Width;
    Self.Columns.Items[i].ImageIndex := Form1.ListView1.Columns.Items[i].ImageIndex;
    Self.Columns.Items[i].MaxWidth := Form1.ListView1.Columns.Items[i].MaxWidth;
    Self.Columns.Items[i].MinWidth := Form1.ListView1.Columns.Items[i].MinWidth;
    Self.Columns.Items[i].Tag := Form1.ListView1.Columns.Items[i].Tag;
    Self.Columns.Items[i].Width := Form1.ListView1.Columns.Items[i].Width;
  end;
end;


Das ListView wird zwar erstellt, aber die columns werden nicht übernommen...

Leider funzt Self := Form1.listView1 nicht, so muss ich alle eigenschaften ändern...

_________________
Gehirn: ein Organ, mit dem wir denken, daß wir denken. - Ambrose Bierce
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Mo 05.04.04 20:10 
Probiers mal so:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
type
  TBlahList = class(TListView)
    private
    public
      constructor create(AOwner: TComponent);
    end;

constructor TBlahList.create(AOwner : TComponent);
var
  i: Integer;
  aColumn: TListColumn;
begin
  inherited;
  Self.Parent := Form1.TabSheet2;
  Self.Align := Form1.ListView1.Align;
  //Self.Columns := Form1.ListView1.Columns;
  Self.OnInfoTip := Form1.ListView1InfoTip;
  for i := 0 to Form1.ListView1.Columns.Count - 1 do
  begin
    aColumn := Self.Columns.Add;
    with Form1.ListView1.Columns.Items[i] do
    begin
      aColumn.Alignment := Alignment;
      aColumn.AutoSize := AutoSize;
      aColumn.Caption := Caption;
      aColumn.ImageIndex := ImageIndex;
      aColumn.MaxWidth := MaxWidth;
      aColumn.MinWidth := MinWidth;
      aColumn.Tag := Tag;
      aColumn.Width := Width;
    end;
  end;
end;

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
Chatfix Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1583
Erhaltene Danke: 10

Win 10, Win 8, Win 7, Win Vista, Win XP
VB.net (VS 2015), MsSQL (T-SQL), HTML, CSS, PHP, MySQL
BeitragVerfasst: Di 06.04.04 09:58 
Da hätte ich auch selbst drauf kommen können...

Danke :)

_________________
Gehirn: ein Organ, mit dem wir denken, daß wir denken. - Ambrose Bierce
Chatfix Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1583
Erhaltene Danke: 10

Win 10, Win 8, Win 7, Win Vista, Win XP
VB.net (VS 2015), MsSQL (T-SQL), HTML, CSS, PHP, MySQL
BeitragVerfasst: Di 06.04.04 20:07 
Ich hab mich wohl zu früh gefreut...
Leider funktioniert das auch nicht :cry:


Ich bin doof... klappt doch, hatte den ViewStyle nicht eingestellt :roll:

_________________
Gehirn: ein Organ, mit dem wir denken, daß wir denken. - Ambrose Bierce