hi..
in your demo advStringGrid, i can take a real value.. not showed value..
so i set combobox in advcolumnGrid like your demo, but it's doen't show a description..
how can i solve..?
or
actually i want to make combobox in advcolumnGrid using recoredset.
for example (already i get a recored set using DB)
code / description
code1 / desc1
code2 / desc3
code3 / desc3
1. how can i make combobox?
2. how to change the description automately, when i set a code to combobox.
3. how to get a code, when user select a description of combobox..
please help me...
this below is the your demo for testing to set combobox in AdvColumnGrid..
{*************************************************************************}
{ TAdvStringGrid demo unit }
{ }
{ written by TMS Software }
{ copyright ?1998-2011 }
{ Email : info@tmssoftware.Com }
{ Web : http://www.tmssoftware.Com }
{ }
{ The source code is given as is. The author is not responsible }
{ for any possible damage done due to the use of this code. }
{ The component can be freely used in any application. The complete }
{ source code remains property of the author and may not be distributed, }
{ published, given or sold in any form as such. No parts of the source }
{ code can be included in any other component or application without }
{ written authorization of the author. }
{*************************************************************************}
unit Unit1;
{ TAdvStringGrid demo unit }
{ }
{ written by TMS Software }
{ copyright ?1998-2011 }
{ Email : info@tmssoftware.Com }
{ Web : http://www.tmssoftware.Com }
{ }
{ The source code is given as is. The author is not responsible }
{ for any possible damage done due to the use of this code. }
{ The component can be freely used in any application. The complete }
{ source code remains property of the author and may not be distributed, }
{ published, given or sold in any form as such. No parts of the source }
{ code can be included in any other component or application without }
{ written authorization of the author. }
{*************************************************************************}
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, BaseGrid, AdvGrid, StdCtrls, AdvObj, XPMan, AdvCGrid;
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, BaseGrid, AdvGrid, StdCtrls, AdvObj, XPMan, AdvCGrid;
type
TForm1 = class(TForm)
AdvStringGrid1: TAdvStringGrid;
Button1: TButton;
Button2: TButton;
ListBox1: TListBox;
AdvColumnGrid1: TAdvColumnGrid;
procedure FormCreate(Sender: TObject);
procedure AdvStringGrid1GetDisplText(Sender: TObject; ACol, ARow: Integer;
var Value: string);
procedure AdvStringGrid1CellValidate(Sender: TObject; ACol, ARow: Integer;
var Value: string; var Valid: Boolean);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
TForm1 = class(TForm)
AdvStringGrid1: TAdvStringGrid;
Button1: TButton;
Button2: TButton;
ListBox1: TListBox;
AdvColumnGrid1: TAdvColumnGrid;
procedure FormCreate(Sender: TObject);
procedure AdvStringGrid1GetDisplText(Sender: TObject; ACol, ARow: Integer;
var Value: string);
procedure AdvStringGrid1CellValidate(Sender: TObject; ACol, ARow: Integer;
var Value: string; var Valid: Boolean);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.AdvStringGrid1CellValidate(Sender: TObject; ACol,
ARow: Integer; var Value: string; var Valid: Boolean);
begin
Value := IntToStr(integer(advstringgrid1.ComboBox.Items.Objects[advstringgrid1.ComboBox.ItemIndex]));
end;
ARow: Integer; var Value: string; var Valid: Boolean);
begin
Value := IntToStr(integer(advstringgrid1.ComboBox.Items.Objects[advstringgrid1.ComboBox.ItemIndex]));
end;
procedure TForm1.AdvStringGrid1GetDisplText(Sender: TObject; ACol,
ARow: Integer; var Value: string);
var
i, e: integer;
begin
val(value, i, e);
if e = 0 then
Value := advstringgrid1.ComboBox.Items;
end;
ARow: Integer; var Value: string);
var
i, e: integer;
begin
val(value, i, e);
if e = 0 then
Value := advstringgrid1.ComboBox.Items;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
listbox1.Items.Add(advstringgrid1.Cells[advstringgrid1.Col, advstringgrid1.Row]);
listbox1.Items.Add(AdvColumnGrid1.Cells[AdvColumnGrid1.Col, AdvColumnGrid1.Row]);
end;
begin
listbox1.Items.Add(advstringgrid1.Cells[advstringgrid1.Col, advstringgrid1.Row]);
listbox1.Items.Add(AdvColumnGrid1.Cells[AdvColumnGrid1.Col, AdvColumnGrid1.Row]);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
listbox1.Items.Add(advstringgrid1.GridCells[advstringgrid1.Col, advstringgrid1.Row]);
listbox1.Items.Add(AdvColumnGrid1.GridCells[AdvColumnGrid1.Col, AdvColumnGrid1.Row]);
end;
begin
listbox1.Items.Add(advstringgrid1.GridCells[advstringgrid1.Col, advstringgrid1.Row]);
listbox1.Items.Add(AdvColumnGrid1.GridCells[AdvColumnGrid1.Col, AdvColumnGrid1.Row]);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
// string grid sample //
advstringgrid1.Options := advstringgrid1.Options + [goEditing];
advstringgrid1.DefaultEditor := edComboList;
advstringgrid1.ComboBox.Items.AddObject('Germany', TObject(0));
advstringgrid1.ComboBox.Items.AddObject('France', TObject(1));
advstringgrid1.ComboBox.Items.AddObject('Spain', TObject(2));
advstringgrid1.ComboBox.Items.AddObject('Russia', TObject(3));
begin
// string grid sample //
advstringgrid1.Options := advstringgrid1.Options + [goEditing];
advstringgrid1.DefaultEditor := edComboList;
advstringgrid1.ComboBox.Items.AddObject('Germany', TObject(0));
advstringgrid1.ComboBox.Items.AddObject('France', TObject(1));
advstringgrid1.ComboBox.Items.AddObject('Spain', TObject(2));
advstringgrid1.ComboBox.Items.AddObject('Russia', TObject(3));
advstringgrid1.Cells[1, 1] := '0';
advstringgrid1.Cells[1, 2] := '1';
advstringgrid1.Cells[1, 3] := '2';
advstringgrid1.Cells[1, 4] := '3';
advstringgrid1.Cells[1, 2] := '1';
advstringgrid1.Cells[1, 3] := '2';
advstringgrid1.Cells[1, 4] := '3';
// column grid test //
AdvColumnGrid1.Options := AdvColumnGrid1.Options + [goEditing];
AdvColumnGrid1.DefaultEditor := edComboList;
AdvColumnGrid1.Columns.Items[2].ComboItems.AddObject('Germany', TObject(0));
AdvColumnGrid1.Columns.Items[2].ComboItems.AddObject('France' , TObject(1));
AdvColumnGrid1.Columns.Items[2].ComboItems.AddObject('Spain' , TObject(2));
AdvColumnGrid1.Columns.Items[2].ComboItems.AddObject('Russia' , TObject(3));
AdvColumnGrid1.Options := AdvColumnGrid1.Options + [goEditing];
AdvColumnGrid1.DefaultEditor := edComboList;
AdvColumnGrid1.Columns.Items[2].ComboItems.AddObject('Germany', TObject(0));
AdvColumnGrid1.Columns.Items[2].ComboItems.AddObject('France' , TObject(1));
AdvColumnGrid1.Columns.Items[2].ComboItems.AddObject('Spain' , TObject(2));
AdvColumnGrid1.Columns.Items[2].ComboItems.AddObject('Russia' , TObject(3));
AdvColumnGrid1.Cells[1, 1] := '0';
AdvColumnGrid1.Cells[1, 2] := '1';
AdvColumnGrid1.Cells[1, 3] := '2';
AdvColumnGrid1.Cells[1, 4] := '3';
AdvColumnGrid1.Cells[1, 2] := '1';
AdvColumnGrid1.Cells[1, 3] := '2';
AdvColumnGrid1.Cells[1, 4] := '3';
end;
end.