Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Начинающим";
Текущий архив: 2006.08.06;
Скачать: [xml.tar.bz2];

Вниз

Компонент в 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;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.46 MB
Время: 0.012 c
2-1152602497
Квэнди
2006-07-11 11:21
2006.08.06
ПРоблема с Gettext совместно с своим Winproc


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


2-1153373615
TimTimon
2006-07-20 09:33
2006.08.06
Форма


2-1153379243
novill
2006-07-20 11:07
2006.08.06
Не получается послать сообшение (SendMessage)


2-1153411217
Ivolg
2006-07-20 20:00
2006.08.06
Сообщение





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский