![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
Компонент в STRINGGRIDE [D6, 95/98]
Rubey © (2006-07-18 08:17:00)Ввожу данные через STRINGGRID и для этого вызываю дополнительную форму кликом по ячейке. А как вызвать таким кликом только компонент ( например EDIT или MASKEDIT ). Помогите, знатоки , советом - буду Вам очень благодарен.
Рубей - 18.07.2006
Desdechado (2006-07-18 11:02:00) [1]Rubey (18.07.06 08:17)
То ты терзал DBGrid на такие извращения, теперь к стринговому перешел?
Чем тебя не устраивает редактор в самом гриде?
Поройся в Options, много интересного найдешь.
PSPF2003 (2006-07-18 09:02:00) [2]Хм… Не совсем понял что тебе надо. То нет. В примере по щелчку по гриду поевляется на нем необходимый компонент.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, StdCtrls, Buttons, Mask;
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
dataEdit1: TMaskEdit;
dataEdit3: TMaskEdit;
ComboBox1: TComboBox;
ComboBox2: TComboBox;
Memo1: TMemo;
Button1: TButton;
Memo2: TMemo;
Button2: TButton;
Label1: TLabel;
Label2: TLabel;
procedure FormShow(Sender: TObject);
procedure StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
procedure dataEdit1Change(Sender: TObject);
procedure dataEdit3Change(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
procedure ComboBox2Change(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Types;
{$R *.dfm}
procedure TForm1.FormShow(Sender: TObject);
begin
StringGrid1.Cells[1,0]:='Ãîä ðîæäåíèÿ';
StringGrid1.Cells[2,0]:='Ìåñòî ðîæäåíèÿ';
StringGrid1.Cells[3,0]:='Òåëåôîí';
StringGrid1.Cells[4,0]:='Ñåìåéíîå ïîëîæåíèå';
StringGrid1.Cells[0,1]:='Èâàíîâ';
StringGrid1.Cells[0,2]:='Ïåòðîâ';
StringGrid1.Cells[0,3]:='Ñèäîðîâ';
StringGrid1.Cells[0,4]:='Ñìèðíîâ';
end;
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
dataEdit1.Visible:=True;
if (gdFocused in state) then
begin
if ACol=1 then
begin
dataEdit1.Text:=StringGrid1.Cells[ACol,ARow];
dataEdit1.left:=Rect.Left+StringGrid1.Left+2;
dataEdit1.Top:=Rect.Top+StringGrid1.Top+2;
dataEdit1.Width:=Rect.Right-Rect.Left;
dataEdit1.Height:=Rect.Bottom-Rect.Top;
dataEdit1.Visible:=True;
Exit;
end;
end;
ComboBox2.Visible:=false;
if (gdFocused in state) then
begin
if ACol=2 then
begin
ComboBox2.Text:=StringGrid1.Cells[ACol,ARow];
ComboBox2.left:=Rect.Left+StringGrid1.Left+2;
ComboBox2.Top:=Rect.Top+StringGrid1.Top+2;
ComboBox2.Width:=Rect.Right-Rect.Left;
ComboBox2.Height:=Rect.Bottom-Rect.Top;
ComboBox2.Visible:=True;
Exit;
end;
end;
if (gdFocused in state) then
begin
if ACol=3 then
begin
dataEdit3.Text:=StringGrid1.Cells[ACol,ARow];
dataEdit3.left:=Rect.Left+StringGrid1.Left+2;
dataEdit3.Top:=Rect.Top+StringGrid1.Top+2;
dataEdit3.Width:=Rect.Right-Rect.Left;
dataEdit3.Height:=Rect.Bottom-Rect.Top;
dataEdit3.Visible:=True;
Exit;
end;
end;
ComboBox1.Visible:=false;
if (gdFocused in state) then
begin
if ACol=4 then
begin
ComboBox1.Text:=StringGrid1.Cells[ACol,ARow];
ComboBox1.left:=Rect.Left+StringGrid1.Left+2;
ComboBox1.Top:=Rect.Top+StringGrid1.Top+2;
ComboBox1.Width:=Rect.Right-Rect.Left;
ComboBox1.Height:=Rect.Bottom-Rect.Top;
ComboBox1.Visible:=True;
Exit;
end;
end;
end;
procedure TForm1.dataEdit1Change(Sender: TObject);
begin
StringGrid1.Cells[StringGrid1.Col,StringGrid1.Row]:=dataEdit1.Text;
end;
procedure TForm1.dataEdit3Change(Sender: TObject);
begin
StringGrid1.Cells[StringGrid1.Col,StringGrid1.Row]:=dataEdit3.Text;
end;
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
StringGrid1.Cells[StringGrid1.Col,StringGrid1.Row]:=ComboBox1.Text;
end;
procedure TForm1.ComboBox2Change(Sender: TObject);
begin
StringGrid1.Cells[StringGrid1.Col,StringGrid1.Row]:=ComboBox2.Text;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ComboBox2.Items.Text:=Memo1.Lines.Text;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Label2.Caption:='Ñåìåéíîå'#13+'ïîëîæåíèå';
ComboBox2.Items.Text:=Memo1.Lines.Text;
ComboBox1.Items.Text:=Memo2.Lines.Text;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
ComboBox1.Items.Text:=Memo2.Lines.Text;
end;
end.