procedure TForm1.SelectClick(Sender: TObject);
var
x: word;
TempBookmark: TBookMark;
begin
DBGrid1.Datasource.Dataset.DisableControls;
with DBgrid1.SelectedRows do if Count <> 0 then begin
TempBookmark:= DBGrid1.Datasource.Dataset.GetBookmark;
for x:= 0 to Count - 1 do begin
if IndexOf(Items[x]) > –1 then begin
DBGrid1.Datasource.Dataset.Bookmark:= Items[x];
showmessage(DBGrid1.Datasource.Dataset.Fields[1].AsString);
end;
end;
end;
DBGrid1.Datasource.Dataset.GotoBookmark(TempBookmark);
DBGrid1.Datasource.Dataset.FreeBookmark(TempBookmark);
DBGrid1.Datasource.Dataset.EnableControls;
end;
Edit
Массив Edit-компонентов
Procedure DoSomethingWithEditControls;
Var K: Integer;
EditArray: Array[0..99] of Tedit;
begin
Try
For K:= 0 to 99 do begin
EditArray[K]:= TEdit.Create(Self);
EditArray[K].Parent:= Self;
SetSomeOtherPropertiesOfTEdit; {Устанавливаем необходимые свойства TEdit}
Left:= 100; Top:= K*10;
OnMouseMove:= WhatToDoWhenMouseIsMoved; {Что-то делаем при перемещении мыши}
end;
DoWhateverYouWantToDoWithTheseEdits; {Делаем все что хотим с полученным массивом Edit-компонентов}
Finally
For K:= 0to 99do EditArray[K].Free;
end;
Примечание: узнать доступные свойства компонента можно непосредственно в инспекторе объектов и (или) в текстовом режиме вашей формы (щелкните на форме правой кнопкой мыши и выберите пункт View as Text)
Label
3D-рамка для текстовых компонентов
Один из примеров создания текстового компонента с трехмерной декоративной контурной рамкой (для создания компонента потребовалось около получаса. Он демонстрирует только принцип получения рамки. Я не стал колдовать над свойствами типа ParentFont…, т.к. это заняло бы еще немало времени и места).
unit IDSLabel;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls;
type TIDSLabel = class(TBevel)
private
{ Private declarations }
FAlignment: TAlignment;
FCaption: String;
FFont: TFont;
FOffset: Byte;
FOnChange: TNotifyEvent;
procedure SetAlignment(taIn : TAlignment);
procedure SetCaption(const strIn: String);
procedure SetFont(fntNew: TFont);
procedure SetOffset(bOffNew: Byte);
protected
{ Protected declarations }
constructor Create(compOwn: TComponent); override;
destructor Destroy; override;
procedure Paint; override;
public
{ Public declarations }
published
{ Published declarations }
property Alignment: TAlignment read FAlignment write SetAlignment default taLeftJustify;
property Caption: String read FCaption write SetCaption;
property Font: TFont read FFont write SetFont;
property Offset: Byte read FOffset write SetOffset;
property OnChange: TNotifyEvent read FOnChange write FOnChange;
end;
implementation
constructor TIDSLabel.Create;
begin
inherited Create(compOwn);
FFont:= TFont.Create;
with compOwn as TForm do FFont.Assign(Font);
Offset:= 4;
Height:= 15;
end;