Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2006.08.06;
Скачать: CL | DM;

Вниз

Компонент в STRINGGRIDE   Найти похожие ветки 

 
Rubey   (2006-07-18 08:17) [0]

Ввожу  данные  через   STRINGGRID  и  для   этого  вызываю  дополнительную  форму  кликом  по  ячейке. А  как  вызвать  таким  кликом  только  компонент ( например EDIT или  MASKEDIT ). Помогите, знатоки ,  советом - буду  Вам  очень  благодарен.
Рубей   -  18.07.2006


 
PSPF2003 ©   (2006-07-18 09:02) [1]

Хм… Не совсем понял что тебе надо. То нет. В примере по щелчку по гриду поевляется на нем необходимый компонент.

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.


 
Desdechado ©   (2006-07-18 11:02) [2]

Rubey   (18.07.06 08:17)
То ты терзал DBGrid на такие извращения, теперь к стринговому перешел?
Чем тебя не устраивает редактор в самом гриде?
Поройся в Options, много интересного найдешь.



Страницы: 1 вся ветка

Текущий архив: 2006.08.06;
Скачать: CL | DM;

Наверх




Память: 0.48 MB
Время: 0.037 c
2-1153077707
Footballer
2006-07-16 23:21
2006.08.06
НЕ МОГУ ГДЕ СКАЧАТЬ НАЙТИ RAIZE COMPONENT


1-1151101641
Аццкий юзар
2006-06-24 02:27
2006.08.06
ADO компоненты в dll - инициализация


15-1152394014
PATRIOT
2006-07-09 01:26
2006.08.06
Как получить звук на входе и воспроизвести его на выходе


3-1149135442
Muzzy
2006-06-01 08:17
2006.08.06
HELP!!! DataSet при Insert ругается, что база read-only.


3-1149150236
Dust
2006-06-01 12:23
2006.08.06
Абра-кадабра в отчёте, FR, Arial (cp Cyrilic), WinXP Rus