Arsip: Combobox didalam cell stringgrid dan radio butto didalam listbox


by LuriDarmawan in Form more 19 years ago 4692
re-posting dr saysansay
ke hapus soalnyaa

Dari pada nungguin org brantem lbh baik ngisi artikel...Mudahan ada manfaatnya...
Sesuai dengan judul artikel ini menjelaskan bagaimana menggunakan combobox didalam cell stringgrid dan Radiobutton didalam listbox...ok dech
Procedure Di Event On Form Create Dimana procedure ini berguna untuk mencreate item2 dari combobox dan listbox1...
procedure TForm1.FormCreate(Sender: TObject);
begin
ListBox1.Style := lbOwnerDrawVariable;
ListBox1.ItemHeight := 20;
ListBox1.Items.Add('Item 1');
ListBox1.Items.Add('Item 2');
ListBox1.Items.Add('Item 3');
ListBox1.Items.Add('Item 4');
ListBox1.Items.Add('Item 5');
with Combobox1 do
begin
StringGrid1.DefaultRowHeight := Height;
Visible := False;
Items.Add('Item1');
Items.Add('Item2');
Items.Add('Item3');
Items.Add('Item4');
Items.Add('Item5');
Text := 'Select an item';
end;
end;
Syntax Highlighted with https://pascal-id.org/syntax


Procedure Ini akan MeNenmpatkan Combobox pada Colom Dan baris dari Stringgrid
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
StringGrid1.Cells[StringGrid1.Col, StringGrid1.Row] :=
ComboBox1.Items[ComboBox1.ItemIndex];
ComboBox1.Visible := False;
StringGrid1.SetFocus;
end;
Syntax Highlighted with https://pascal-id.org/syntax


Procedure ini bekerja mengvisible combobox yg ada di string grid..
procedure TForm1.ComboBox1Exit(Sender: TObject);
begin
begin
StringGrid1.Cells[StringGrid1.Col, StringGrid1.Row] :=
ComboBox1.Items[ComboBox1.ItemIndex];
ComboBox1.Visible  := False;
StringGrid1.SetFocus;
end;
end;
procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
var
R: TRect;
begin
if (ACol = 1) and (ARow <> 0) then
begin
R := StringGrid1.CellRect(ACol, ARow);
R.Left := R.Left + StringGrid1.Left;
R.Right := R.Right + StringGrid1.Left;
R.Top := R.Top + StringGrid1.Top;
R.Bottom := R.Bottom + StringGrid1.Top;
with Combobox1 do
begin
Left := R.Left + 1;
Top := R.Top + 1;
Width := (R.Right + 1) - R.Left;
Height := (R.Bottom + 1) - R.Top;
Visible := True;
SetFocus;
end;
end;
CanSelect := True;
end;
procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
var
drawRect: TRect;
begin
with ListBox1.Canvas do
begin
FillRect(rect);
drawRect.Left := rect.Left + 1;
drawRect.Right := Rect.Left + 13;
drawRect.Bottom := Rect.Bottom;
drawRect.Top := Rect.Top;
if odSelected in State then
DrawFrameControl(Handle, drawRect, DFC_BUTTON, DFCS_BUTTONRADIO or DFCS_CHECKED)
else
DrawFrameControl(Handle, drawRect, DFC_BUTTON, DFCS_BUTTONRADIO);
TextOut(15, rect.Top + 3, ListBox1.Items[Index]);
end;
end;
Syntax Highlighted with https://pascal-id.org/syntax


kira2 gambarnya akan seperti ini

AI Forward

๐Ÿš€ We're thrilled to partner with Alibaba Cloud for "AI Forward - Alibaba Cloud Global Developer Summit 2025" in Jakarta! Join us and explore the future of AI. Register now: https://int.alibabacloud.com/m/1000400772/
#AlibabaCloud #DeveloperSummit #Jakarta #AIFORWARD

Local Business Directory, Search Engine Submission & SEO Tools FreeWebSubmission.com SonicRun.com