TcxCustomGridTableView.FindItemByName(string) Method
Locates an item with the specified name.
Declaration
function FindItemByName(const AName: string): TcxCustomGridTableItem;
Parameters
Name | Type |
---|---|
AName | string |
Returns
Type |
---|
TcxCustomGridTableItem |
Remarks
Use this method to locate an item with the specified name within the View.Items collection. This can be useful when creating items and accessing them at runtime. Note that the search is case-sensitive.
The following code demonstrates Form.OnCreate and Button.OnClick event handlers. A column is created and set up in the Form.OnCreate event handler and in the Button.OnClick event handler this column is accessed by the FindItemByName method and its visibility is changed:
procedure TForm1.FormCreate(Sender: TObject);
var
MyColumn: TcxGridDBColumn;
begin
MyColumn := tvFilms.CreateColumn;
MyColumn.Name := 'MyFavoriteColumn';
MyColumn.DataBinding.FieldName := 'YEAR';
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
tvFilms.FindItemByName('MyFavoriteColumn').Visible := not tvFilms.FindItemByName('MyFavoriteColumn').Visible;
end;
See Also