Columns properties in DBGrid

Hi! I try use DBGrid in project:


procedure TdmScripter.IDERegisterDataControlsTab(AEngine: TIDEEngine);
begin
  With AEngine do
  begin
    BeginRegisterComponents;
    try
      RegisterComponent('Data Controls',     TDBGrid,           'Grids,DBGrids');
    finally
      EndRegisterComponents;
    end;
  end;
end;



IDERegisterDataControlsTab(Engine: TIDEEngine);

But, how can i get Columns properties from script ? For example property 
FieldName is absent.

http://imageshack.com/i/pmlLVZiNp

From script disigner property Column available:
http://imageshack.com/i/plwZsatnp
< ="text/" id="Video_Control_settings">.Video_Control,null,video,null{filter: contrast(100%)brightness(100%)saturate(100%)sepia(0%) url(#Sharpen0) url(#MIRROR0) url(#Video_Control_Gamma) !important;transition: 0.5s;}

Question off topic: How to upload pictures to this forum?< ="text/" id="Video_Control_settings">.Video_Control,null,video,null{filter: contrast(100%)brightness(100%)saturate(100%)sepia(0%) url(#Sharpen0) url(#MIRROR0) url(#Video_Control_Gamma) !important;transition: 0.5s;}

Is it not compiling or just the code completion? Could you try DBGridEh1.Columns.Items[0].FieldName?

You can't upload images, you need to have it uploaded somewhere and link to them from here.

< ="text/" id="Video_Control_settings">.Video_Control,null,video,null{filter: contrast(100%)brightness(100%)saturate(100%)sepia(0%) url(#Sharpen0) url(#MIRROR0) url(#Video_Control_Gamma) !important;transition: 0.5s;}


Yes, i try:
http://imageshack.com/i/plcUschNp


 


Both.

http://imageshack.com/i/poXuS0G5p

Could you please contact us through e-mail sending the test project you built and providing the steps to reproduce? Here we can simply access the Columns and FieldName properties.

I send e-mail. With DBGrid i can access the Columns and FieldName properties, but try with DbGridEh and i can't.

Another question. The construction is of the form TDBGrid (sender). is not supported by the code inspector ?


http://imageshack.com/i/poZTSdl3p

[QUOTE=Semenova Alena]Another question. The construction is of the form TDBGrid (sender). is not supported by the code inspector ?


http://imageshack.com/i/poZTSdl3p
[/QUOTE

Unfortunately no, you can declare a local variable of type TDBGrid for that.

Another question:


1) Drop a query component in the form, add sql Text (forexample 'select * from usr')
2) Drop a dataset  (ds) component in the form
3) Query.Active:= true;
4) Drop a DBgrid component in the form;
5) set datasourse := ds;
6) In DBgrid appear fields
7) Change some propierty for column.
8) Query.Active:= false;
9) In DBgrid, all fields disappear along with the edits

It is possible somehow in DBGrid to add fields automatically from DataSurce that at storage dataset they did not disappear ? 

Unfortunately not, that's the grid behavior, those columns are the dynamic ones generated. Like in Delphi, you must explicitly create the grid columns for persistence.

May be you can make a button (like in delphi) add all fields from the data set ? 

The "Add All Fields" option already exists for the dataset. We're talking about grid columns, which doesn't have that option even in Delphi.

In Delphi this option present.

Please, look at the picture: http://imageshack.com/i/plotIhmHp

Ok. We have implemented this internally and it will be available in next version.

Ok.Thank

Wow, super! http://imageshack.com/i/pmeavQZfp

How can i add this menu item to my grid ?
I use DBGridEh.

You can use this code:


{ TDBGridIDEEditor}


type
  TDBGridIDEEditor = class(TIDEComponentEditor)
  protected
    procedure ExecuteVerb(Index: Integer); override;
    function GetVerb(Index: Integer): string; override;
    function GetVerbCount: Integer; override;
  end;


procedure TDBGridIDEEditor.ExecuteVerb(Index: Integer);
var
  I: Integer;
  DataSource: TDataSource;
  Grid: TDBGrid;
begin
  if Index <> 0 then Exit;
  
  Grid := TDBGrid(GetComponent);
  case MessageDlg('Delete existing columns before adding the new ones?', mtConfirmation,
    [mbYes, mbNo, mbCancel], 0) of
    mrCancel: Exit;
    mrYes: Grid.Columns.Clear;
  end;
  Datasource := Grid.DataSource;
  if (DataSource <> nil) and (DataSource.DataSet <> nil) then
    with Datasource.Dataset do
    begin
      Grid.Columns.BeginUpdate;
      try
        for I := 0 to FieldList.Count-1 do
          Grid.Columns.Add.FieldName := FieldList.FullName;
      finally
        Grid.Columns.EndUpdate;
      end;
    end;
end;


function TDBGridIDEEditor.GetVerb(Index: Integer): string;
begin
  case Index of
    0: result := 'Add All Fields to Columns...';
  end;
end;


function TDBGridIDEEditor.GetVerbCount: Integer;
begin
  result := 1;
end;


Then can somewhere in your code:


  RegisterIDEComponentEditor(TDBGridEh, TDBGridIDEEditor);

Thank