Knowledge Base Alert May, 2017





TMS TAdvStringGrid:

Locating data in a grid



Via the built-in search footer in the VCL TAdvStringGrid, it is easy and fast to locate data in a grid. This can be done via search and moving to or highlighting the matches or it can be done via narrow down. The default method is search. As the user types in the search edit, a search is performed in the grid and the grid moves to the first matching item. Optionally, other matching items are highlighted. When grid.SearchFooter.SearchColumn is set to a specific column index, the search is only performed in this specific column.

In addition to this search method, a narrow-down is also possible. This is enabled by setting grid.SearchFooter.SearchType := stNarrowDown. While the user types in the search edit, all rows that do not match the condition are removed from the grid. Just like with regular search, the narrow-down can be performed on all column values or only on the specified column via grid.SearchFooter.SearchColumn.

In this example, the search type is set to stNarrowDown, the search column to 5 and as the user types '6', only rows with cars with 6 cylinders are displayed:

TMS TAdvStringGrid:

Adding a hyperlink to a cell in TAdvStringGrid without protocol specifier



Suppose you want to make www.google.com clickable in a grid cell, you could do this by adding HTML formatted text :
grid.Cells[1,1] := '<a href="http://www.google.com">www.google.com</a>';

An alternative shorter way is to use grid.URLShow = true. This will detect the protocol http:// as part of an URL. If you do not want to see the protocol however, you can set grid.URLFull := false.

So, with these settings:

Grid.URLFull := false;
Grid.URLShow := true;
Grid.Cells[1,1] := 'http://www.google.com'; 

The clickable link www.google.com will be automatically visible in cell 1,1:

TMS TAdvEdit:

Setting the label background color of the label associated with TAdvEdit



You can set this via:

AdvEdit.LabelTransparent := false;
AdvEdit.EditLabel.Color := clYellow;

TMS TDBPlanner:

How to change the background color and specify a hint for a specific day



You can change the background color for a specific day via the event OnGetDayProp.

This event for example, sets the background color for easter Sunday day to yellow:

procedure TForm3.PlannerMonthView1GetDayProp(Sender: TObject; Date:
TDateTime;
  var Caption: string; CaptionBrush: TBrush; AFont: TFont; var BKColor,
  BKColorTo: TColor);
begin
  if date = encodedate(2017,4,16) then
    bkcolor := clYellow;
end;

You can add an additional text, also via this OnGetDayProp event:

procedure TForm3.PlannerMonthView1GetDayProp(Sender: TObject; Date:
TDateTime;
  var Caption: string; CaptionBrush: TBrush; AFont: TFont; var BKColor,
  BKColorTo: TColor);
begin
  if date = encodedate(2017,4,16) then
  begin
    bkcolor := clYellow;
    Caption := 'easter';
  end;
end;

You can specify a hint for a specific date via the event OnGetDateHintString:

procedure TForm3.FormCreate(Sender: TObject); begin
  PlannerMonthView1.ShowHint := true;
end;

procedure TForm3.PlannerMonthView1GetDateHintString(Sender: TObject;
  dt: TDateTime; var isEvent: Boolean; var EventHint: string); begin
  if dt = encodedate(2017,4,16) then
  begin
    EventHint := 'easter';
  end;
end;


TMS TAdvRichEditor:

Programmatic access to content of TAdvRichEditor



This code snippet shows how to access the content of the richeditor and in this case, extract the text as plain text:

var
  i: integer;
  el: TREElement;
  txt: TTextElement;
  s : string;

begin
  s := '';

  for i := 0 to AdvRichEditor1.Context.Content.Count - 1 do
    begin
      el := AdvRichEditor1.Context.Content.Items[i];
      if el is TTextElement then
        s := s + (el as TTextElement).Text;
      if el is TLineBreakElement then
        s := s + #13#10;
    end;
end;


TMS FMX RichEditor:

How to add an image to TTMSFMXRichEditor from a BitmapContainer



Assign a BitmapContainer to TTMSFMXRichEditor and add an image to the BitmapContainer and set its name, for example to 'Img1'.

Next, insert a reference to this BitmapContainer via for example:
  TMSFMXRichEditor1.AddNamedPicture(32,32,'img1');


TMS FMX TableView:

Setting a search hint text for the TTMSFMXTableView search edit control



You can access the internal search editor for the TTMSFMXTableView component and customize the search text. Do this from the TMSFMXTableView .OnApplyStyleLookup event as when this event is triggered, the internal search edit control is created:
procedure TForm1.TMSFMXTableView1ApplyStyleLookup(Sender: TObject); var edSearch: TTMSFMXSearchEdit;
begin
  edSearch := TMSFMXTableView1.GetSearchEdit;
  edSearch.TextPrompt := 'Enter text to search here'; 
end;


TMS FMX NavBar:

How to hide the footer



Open the FMX control custom style editor and select the footer from the style editor from where you can either set the footer height to zero or set footer.Visible = false

KB93




As always, we thank all users for the numerous inputs, feedback, comments and suggestions. This is an invaluable help to steer our developments here at TMS software. We continue to look forward to all your further communications to direct our team to provide you better tools and components for your needs.

Kind regards,
TMS software team
Email: info@tmssoftware.com
Web: http://www.tmssoftware.com
Support, FAQ & Manuals: http://www.tmssoftware.com/site/support.asp


Follow latest developments at tmssoftware.com




NOTICE: If you wish to unsubscribe from the TMS software Newsletter, please click here.