sw4all
Members-
Content Count
8 -
Joined
-
Last visited
Everything posted by sw4all
-
Hello to everybody. I need to add a button to each cell and use one click function. Unfortunately I get an error Access violation at address ... Thank you all. Daniel public { Public declarations } procedure btnChangeSClick(Sender: TObject); ... ... procedure TfrmMain.btnChangeSkupinaClick(Sender: TObject); begin frmSelectS.gridName := 'TEST'; frmSelectS.ShowModal; end; procedure TfrmMain.grid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); var Field: TField; fixRect : TRect; btnChangeS: TButton; begin Field := Column.Field; if (Column.Index = 0) then begin try btnChangeS.Create(grid1); btnChangeS.Parent := grid1; btnChangeS.Visible := True; btnChangeS.Caption := '...'; btnChangeS.Width := 25; btnChangeS.Height := (Rect.Bottom - Rect.Top) - 2; btnChangeS.Left := (Rect.Left + Rect.Width) - (btnChangeS.Width +1); btnChangeS.Top := Rect.Top + 1; btnChangeS.OnClick := btnChangeSClick; grid1.DefaultDrawColumnCell(Rect, DataCol, Column, State); except On E: exception do begin ShowMessage(E.Message); end; end; end; end;
-
Is there any way for the button to still be visible, not only when a cell is selected? So that the user can see which cells he can edit.
-
Yes thank you. The problem is that dgEditing will not be enabled, so the button will not appear. Oh, just set DBGrid readOnly: = True;
-
I see one more error and that is that the procedure still creates more and more buttons. Please look in the upper left corner. Sample video. Debut 2021-08-15 17_57_46.mp4
-
Yes. Thank you so much for your quick help. Everything is working.
-
Hi, I have a problem with ScrollBox. When rotating Rectangle, the scroll bar does not appear and aligns Rectangle -200 to the left. The left and right image pieces are missing and the scroll bar is not displayed. procedure TFrmMain.ButtonRotateClick(Sender: TObject); begin Rectangle1.RotationAngle := Rectangle1.RotationAngle + 90; end; procedure TForm110.FormResize(Sender: TObject); begin ScrollBox1.Width := frmMain.Width -5; end; procedure TFrmMain.FormShow(Sender: TObject); begin Rectangle1.Position.X := 0; Rectangle1.Position.Y := 0; Rectangle1.Width := Image1.Bitmap.Width; Rectangle1.Height := Image1.Bitmap.Height; // rectangle1.Parent := ScrollBox1; // Image1.Parent := Rectangle1; end; Image angle-0 is Rectangle.RotationAngle := 0; Image angle-90 is Rectangle.RotationAngle = 90;
-
Hi, I have a TImageViewer component on my form. At runtime, I create the TRectangle component and place it in ImageViewer. Now I need the Rectangle component to be automatically resized (Height and Width) by ImageViewer.BitmapScale and also to move in the correct position X and Y. Please help. Thank you StartPositionX := 1032; // rectangle1.Position.X StartPositionY := 304; // rectangle1.Position.Y procedure TfrmMain.ImageViewer1CalcContentBounds(Sender: TObject; var ContentBounds: TRectF); begin rectangle1.Scale.X := imgNahled.BitmapScale; rectangle1.Scale.Y := imgNahled.BitmapScale; rectangle1.Position.X := StartPositionX * imgNahled.BitmapScale; rectangle1.Position.Y := StartPositionY * imgNahled.BitmapScale; end;
-
Hi to all. I have created TButton on the form and 2x TLabel in it. When clicking TButton I need to change the text in one TLabel. myButton is created on runtime. type TfrmMain = class(TForm) procedure FormCreate(Sender: TObject); private { Private declarations } procedure newButtonClick(Sender: TObject); procedure newProductButtonClick(Sender: TObject); { Public declarations } end; implementation procedure TfrmMain.newProductButtonClick(Sender: TObject); var comp: TComponent; begin FlowLayout1.BeginUpdate; // find component comp := FindComponent('LabelProductPrice'+TButton(Sender).Name); if (comp is TLabel) then begin (comp as TLabel).Text := IntToStr(StrToInt((comp as TLabel).Text) +1); end else begin // create new button newButton := TButton.Create(Self); newButton.Parent := FlowLayout1; newButton.Name := 'btn'+TButton(Sender).Name; newButton.Text := ''; newButton.Hint := '1'; newButton.Width := FlowLayout1.Width; newButton.Height := 80; newButton.OnClick := newButtonClick; newButton.Tag := TButton(Sender).Tag; newButton.OnMouseEnter := newButtonMouseEnter; newButton.OnMouseMove := newButtonMouseMove; newButton.OnMouseLeave := newButtonMouseLeave; newButton.Width := FlowLayout1.Width -3; newButton.OnClick := newButtonClick; LabelProductName := TLabel.Create(Self); LabelProductName.Parent := newButton; LabelProductName.Align := TAlignLayout.Top; LabelProductName.Text := TButton(Sender).Text; LabelProductName.Hint := newButton.Hint; LabelProductName.Margins.Left := 3; LabelProductName.Margins.Right := 3; LabelProductName.Margins.Bottom := 3; LabelProductName.Margins.Top := 3; LabelProductName.TextAlign := TTextALign.Center; LabelProductName.Name := 'LabelOne'+TButton(Sender).Name; LabelProductName.AutoSize := True; LabelProductName.TextSettings.FontColor := TAlphaColors.Red; LabelProductName.StyledSettings := LabelProductName.StyledSettings - [TStyledSetting.Family, TStyledSetting.Size,TStyledSetting.FontColor]; LabelProductName.OnClick := newButtonClick; LabelProductPrice := TLabel.Create(Self); LabelProductPrice.Parent := newButton; LabelProductPrice.Align := TAlignLayout.Bottom; LabelProductPrice.Text := TButton(Sender).Hint; LabelProductPrice.Margins.Left := 3; LabelProductPrice.Margins.Right := 3; LabelProductPrice.Margins.Bottom := 3; LabelProductPrice.Margins.Top := 3; LabelProductPrice.AutoSize := True; LabelProductPrice.TextAlign := TTextALign.Center; LabelProductPrice.Name := 'LabelTwo'+TButton(Sender).Name; LabelProductPrice.Tag := TButton(Sender).Tag; LabelProductPrice.OnClick := newButtonClick; end; FlowLayout1.EndUpdate; end; procedure TfrmMain.FormCreate(Sender: TObject); var i: integer; begin for i := 10 downto 1 do begin ProductButton := TButton.Create(Self); ProductButton.Parent := Panel1; ProductButton.Name := 'btn'+i.ToString; ProductButton.Text := 'product '+i.ToString; ProductButton.Hint := i.ToString; ProductButton.Height := 80; ProductButton.Width := Panel1.Width -3; ProductButton.Align := TAlignLayout.Top; ProductButton.Tag := i; ProductButton.OnClick := newProductButtonClick; end; end; procedure TfrmMain.myButtonClick(Sender: TObject); var comp: TComponent; begin comp := FindComponent('LabelTwo'+TButton(Sender).Tag.ToString); if (comp is TLabel) then begin TLabel(comp).Text := IntToStr(StrToInt((comp as TLabel).Text) -1); end; end; Thank you.