Hallo Ich möchte in einem Clientdataset einen Artikel Eingeben und abspeichern.
Nun möchte ich einen Button diesen Artikelnamen als Caption Übergeben.Es normal über eine Tstringlist laufen lassen geht ohne Probleme sobald ich aber das Clientdataset1 als Quelle nutzen will gibt es Fehlermeldungen.
Procedure BreakLongString (Const aString : String; aStringList : TStringList; aMaxLength : Integer); Var
X,X1, XEnd : Integer; Begin
X := 1;
XEnd := Length (aString); While X < XEnd DoBegin
X1 := Min (Xend, X+8); If X1<XEnd ThenBegin While (X1>X) And (aString[X1]<>'') Do Dec (X1); If X1 = X Then X1 := X + 8; End;
aStringList.Add(Copy (aString,X,X1-X+1));
X := X1+1; End End;
function SetMultiLineCaption(const p_Button : TButton;const p_sCaption : String; const p_fAutoAdjust : Boolean = false) : Boolean; begin
Result := false; if SetWindowLong(p_Button.Handle, GWL_STYLE, GetWindowLong(p_Button.Handle, GWL_STYLE) or BS_MULTILINE)> 0 then begin
p_Button.Caption := p_sCaption;
Result := true; end; end;
procedure TForm1.Button1Click(Sender: TObject); var
ts:tstringlist;
i:integer; begin
ts:=tstringlist.Create;
breaklongstring(edit1.Text,ts,8);
i:=ts.Count; if i=1 then
SetMultiLineCaption(self.Button1,ts.Strings[0],true); if i=2 then
SetMultiLineCaption(self.Button1,ts.Strings[0]+#13#10+ts.Strings[1],true); if i=3 then
SetMultiLineCaption(self.Button1,ts.strings[0]+#13#10+ts.strings[1]+#13#10+ts.strings[2],true);
ts.Free; end;
Procedure BreakLongString (Const aString : String; aStringList : TStringList; aMaxLength : Integer); Var
X,X1, XEnd : Integer; Begin
X := 1;
XEnd := Length (aString); While X < XEnd DoBegin
X1 := Min (Xend, X+8); If X1<XEnd ThenBegin While (X1>X) And (aString[X1]<>'') Do Dec (X1); If X1 = X Then X1 := X + 8; End;
aStringList.Add(Copy (aString,X,X1-X+1));
X := X1+1; End End;
function SetMultiLineCaption(const p_Button : TButton;const p_sCaption : String; const p_fAutoAdjust : Boolean = false) : Boolean; begin
Result := false; if SetWindowLong(p_Button.Handle, GWL_STYLE, GetWindowLong(p_Button.Handle, GWL_STYLE) or BS_MULTILINE)> 0 then begin
p_Button.Caption := p_sCaption;
Result := true; end; end;
procedure TForm1.Button1Click(Sender: TObject); var
ts:Tstringlist;
j:integer; begin
ts:=tstringlist.Create;
form1.clientdataset1.recno:=1;
breaklongstring(form1.ClientDataSet1.FieldValues['Warengruppe'],ts,8);
j:=ts.Count; if j=1 then
SetMultiLineCaption(form1.LMDDockspeedbutton1,ts.Strings[0],true); if j=2 then
SetMultiLineCaption(form1.LMDDockspeedbutton1,ts.Strings[0]+#13#10+ts.Strings[1],true); if j=3 then
SetMultiLineCaption(form1.LMDDockspeedbutton1,ts.strings[0]+#13#10+ts.strings[1]+#13#10+ts.strings[2],true);
ts.Free; end;