Frequently Asked Component Specific Questions
Options |
Display all FAQ items |
Displaying items 331 to 345 of 508, page 23 of 34
<< previous next >>
TAdvRichEditor
Supported Delphi versions
Supported Delphi versions
The oldest version of Delphi that is supported for TAdvRichEditor is Delphi XE. TAdvRichEditor internally uses generics which are not available in older versions of Delphi.
TAdvRichEditor
How to add color & font style formatted text
How to add color & font style formatted text
Adding color & font style formatted text to TAdvRichEditor can be done with setting a selection and calling AdvRichEditor.SetSelectionColor() or AdvRichEditor.SetSelectionBold(), etc.. but it can also be done by changing the AdvRichEditor.Font before adding new text.
Sample code:
begin AdvRichEditor1.Font.Style := [fsBold]; AdvRichEditor1.Font.Color := clBlue; AdvRichEditor1.AddText('Hello world,'); AdvRichEditor1.Font.Style := [fsItalic]; AdvRichEditor1.Font.Color := clRed; AdvRichEditor1.AddText('this text is in red italic'); end;
TDBAdvGrid
Persisting column sizes & column order for a TDBAdvGrid
Persisting column sizes & column order for a TDBAdvGrid
Assuming a user can resize & move columns around in a TDBAdvGrid and it is desirable that the last state is saved & restored when the application is restarted, this can be done in following way:
- Set default column order & size state after making the dataset active in the TDBAdvGrid with grid.SetColumnOrder
- When column states are found, restore these from INI file with grid.StringToColumnStates
- When the application closes, save the last state to INI file with grid.ColumnStatesToString
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean); var inif: TINIFile; begin inif := TINIFile.Create('.\settings.ini'); inif.WriteString('STATES','DBADVGRID1',DBAdvGrid1.ColumnStatesToString); inif.Free; end; procedure TForm1.FormCreate(Sender: TObject); var inif: TINIFile; colstates: string; begin adotable1.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=.\CARS.mdb;Persist Security Info=False'; adotable1.Active := true; DBAdvGrid1.SetColumnOrder; DBAdvGrid1.Options := DBAdvGrid1.Options + [goColSizing, goColMoving]; inif := TINIFile.Create('.\settings.ini'); colstates := inif.ReadString('STATES','DBADVGRID1',''); inif.Free; if colstates <> '' then DBAdvGrid1.StringToColumnStates(colstates); end;
TAdvSmoothListBox
Customizing the ItemAppearance
Customizing the ItemAppearance
The appearance of the TAdvSmoothListBox and its items can be fully customized.
Following code:
procedure TForm1.AdvSmoothListBox1ItemBkgDraw(Sender: TObject; Canvas: TCanvas; itemindex: Integer; itemRect: TRect; var defaultdraw: Boolean); var g: TGPGraphics; begin defaultdraw := AdvSmoothListBox1.SelectedItemIndex <> itemindex; if not defaultdraw then begin g := TGPGraphics.Create(Canvas.Handle); g.SetSmoothingMode(SmoothingModeAntiAlias); AdvSmoothListBox1.ItemAppearance.FillSelected.Fill(g, MakeRect(itemrect.Left, itemrect.Top, itemrect.Width, itemrect.Height)); g.Free; end; end; procedure TForm1.FormCreate(Sender: TObject); var it: TAdvSmoothListBoxItem; I: Integer; begin AdvSmoothListBox1.BeginUpdate; AdvSmoothListBox1.Fill.Color := clBlack; AdvSmoothListBox1.ItemAppearance.Fill.Color := clBlack; AdvSmoothListBox1.ItemAppearance.Fill.ColorMirror := clNone; AdvSmoothListBox1.ItemAppearance.Fill.BorderColor := clBlack; AdvSmoothListBox1.ItemAppearance.Fill.GradientType := gtSolid; AdvSmoothListBox1.ItemAppearance.Fill.GradientMirrorType := gtNone; AdvSmoothListBox1.Header.Visible := False; AdvSmoothListBox1.Footer.Visible := False; AdvSmoothListBox1.Sections.BorderColor := AdvSmoothListBox1.ItemAppearance.Fill.Color; AdvSmoothListBox1.ItemAppearance.FillSelected.Assign(AdvSmoothListBox1.ItemAppearance.Fill); AdvSmoothListBox1.ItemAppearance.FillSelected.Color := clWebOrange; AdvSmoothListBox1.ItemAppearance.FillSelected.Rounding := 10; AdvSmoothListBox1.ItemAppearance.FillSelected.RoundingType := rtBoth; AdvSmoothListBox1.DefaultItem.CaptionFont.Color := clWhite; AdvSmoothListBox1.Items.Clear; for I := 0 to 19 do begin it := AdvSmoothListBox1.Items.Add; it.Caption := ''Item '' + inttostr(I + 1); end; AdvSmoothListBox1.EndUpdate; end;
Results in:
TMS VCL WebGMaps
Using latitude/longitude coordinates instead of an address
Using latitude/longitude coordinates instead of an address
It is possible to use latitude/longitude coordinates for the Origin and Destination parameters instead of an address. There is an overload of the GetDirections method available which takes the OriginLatitude, OriginLongitude, DestinationLatitude and DestinationLongitude parameters.
Coordinates are also supported for WayPoints. There is no overload for this, but you can provide the coordinates as a string.
Example:
WayPoints.Clear; WayPoints.Add('48, 5'); WebGMaps1.GetDirections(50, 4, 47, 3, false, tmDriving, usMetric, lnDefault, false, false, WayPoints, false);
TMS FlexCel for VCL & FMX
When generating xls/xlsx files with formulas, Excel shows a message to save when you are closing the file
When generating xls/xlsx files with formulas, Excel shows a message to save when you are closing the file
This message happens when you have any formula in the Excel file, and open it with different Excel versions.
The thing is: If you create a file with formulas in say Excel 2007 and then open the file in Excel 2010, Excel will recalculate all cells and show that message. Sometimes (not always) it also happens in the reverse: If you save with Excel 2010 it might ask you to save when you open in Excel 2007.
This isn’t a FlexCel issue: But in Excel you will normally not see this because in your test machine you will use the same Excel version to save and open the file. But as soon as you start delivering the file to customers, they will start seeing the message.
Now, FlexCel is only one “version": It is not Excel 2003, or 2007, or 2010. So when it creates a file, it needs to say “this file was created with Excel version …” in the file, and this is the value Excel will use to decide if it shows the message or not. If you know that say all your users are in Excel 2013, then you can tell FlexCel to say “this file was saved with Excel 2013” and Excel 2013 users won’t see the dialog. But users of a different version of Excel might.
If you are opening the file in Excel 2013 for example, you can get rid of the dialog by doing:
xls.RecalcVersion = TRecalcVersion.Excel2013;
or just do
xls.RecalcVersion = TRecalcVersion.SameAsInputFile;
to make FlexCel save the “version” used in recalculation as the same version the input file had.
TMS FMX UI Pack
TTMSFMXDirectoryTreeView: Custom painting node
TTMSFMXDirectoryTreeView: Custom painting node
This code snippet shows how to paint a directory node with a trackbar that indicades the free space:
procedure TForm1.FormCreate(Sender: TObject); begin TMSFMXDirectoryTreeView1.NodesAppearance.FixedHeight := 40; TMSFMXDirectoryTreeView1.AddColumn(tvckFreeSpaceAndTotalSize); TMSFMXDirectoryTreeView1.Columns[1].VerticalTextAlign := tvtaLeading; TMSFMXDirectoryTreeView1.LoadDrives; end; procedure TForm1.TMSFMXDirectoryTreeView1AfterDrawNodeText(Sender: TObject; ACanvas: TCanvas; ARect: TRectF; AColumn: Integer; ANode: TTMSFMXTreeViewVirtualNode; AText: string); var r, rs: TRectF; fs, fst: Int64; s: String; begin if AColumn = 1 then begin s := TTMSFMXDirectoryTreeViewNode(ANode.Node).FileName; if ExtractFileDrive(s) + PathDelim = s then begin fst := DiskSize(Ord(UpperCase(s)[1]) - 64); fs := DiskFree(Ord(UpperCase(s)[1]) - 64); if (fst > -1) and (fs > -1) then begin r := ARect; r.Top := r.Bottom - 20; r.Height := 20; InflateRect(r, 0, -2); r.Width := r.Width - 2; r := RectF(Int(r.Left) + 0.5, Int(r.Top) + 0.5, Int(r.Right) - 0.5, Int(r.Bottom) - 0.5); rs := r; rs.Width := rs.Width * fs / fst; ACanvas.Fill.Kind := TBrushKind.Solid; ACanvas.Fill.Color := claWhite; ACanvas.FillRect(r, 0, 0, AllCorners, 1); ACanvas.Fill.Color := claSteelblue; ACanvas.FillRect(rs, 0, 0, AllCorners, 1); if TMSFMXDirectoryTreeView1.IsNodeSelected(ANode.Node) then ACanvas.Stroke.Color := claWhite else ACanvas.Stroke.Color := claDarkgray; ACanvas.DrawRect(r, 0, 0, AllCorners, 1); end; end; end; end;
TMS FMX UI Pack
TTMSFMXTreeView: How to dynamically add nodes
TTMSFMXTreeView: How to dynamically add nodes
This code snippet shows how to dynamically add nodes to the TMSFMXTreeView:
procedure TForm1.FormCreate(Sender: TObject); var n: TTMSFMXTreeViewNode; v: TTMSFMXTreeViewNode; begin TMSFMXTreeView1.BeginUpdate; TMSFMXTreeView1.Nodes.Clear; TMSFMXTreeView1.Columns.Clear; TMSFMXTreeView1.Columns.Add.Text := 'Test'; n := TMSFMXTreeView1.AddNode; n.Text[0] := 'Need load childs after in onBeforeExpandNode event'; v := TMSFMXTreeView1.AddNode(n); v.DataString := 'virtual'; TMSFMXTreeView1.EndUpdate; end; procedure TForm1.TMSFMXTreeView1BeforeExpandNode(Sender: TObject; ANode: TTMSFMXTreeViewVirtualNode; var ACanExpand: Boolean); var v: TTMSFMXTreeViewNode; I: Integer; begin if not Assigned(ANode.Node) then Exit; if ANode.Node.GetChildCount > 0 then begin v := ANode.Node.Nodes[0]; if v.DataString = 'virtual' then begin TMSFMXTreeView1.RemoveNode(v); for I := 0 to 9 do TMSFMXTreeView1.AddNode(ANode.Node).Text[0] := 'Dynamically added node ' + inttostr(I); end; end; end;
TMS IntraWeb Component Pack Pro
TTIWAdvWebGrid: How to add a background image
TTIWAdvWebGrid: How to add a background image
You can use the Background.PictureURL property to add a direct link to an image file. If you wish to use a relative path to link to the image file, just move the image file to a subfolder called “wwwroot” in the folder where the exe file is generated:
TIWDBAdvWebGrid1.Background.PictureURL := 'test.png';
TMS IntraWeb Component Pack Pro
TTIWDBAdvWebGrid: How to display an image based on the original cell value
TTIWDBAdvWebGrid: How to display an image based on the original cell value
You can use the OnGetCellData event to display a custom value based on the original cell value. As you can''t change the column type on the fly, you must add an IMG tag with a direct link to the image file.
Example:
procedure TIWForm1.TIWDBAdvWebGrid1GetCellData(Sender: TObject; RowIndex, ColumnIndex: Integer; var AValue: string); begin if AValue = 'X' then AValue := '<img src="/files/image.png">' end;
Follow these steps to display image from an ImageListin the TIWAdvWebGrid:
- Assign the ImageList to the TIWDBAdvWebGrid.Images property.
- Set the Columns[].ColumnType to ctDataImage.
- Set the index of the Image in the ImageList as the cell value.
TMS VCL WebGMaps
TMS WebGMaps in 64 bit
TMS WebGMaps in 64 bit
To use the components for 64 bit, just make sure the folder where TMS WebGMaps source are installed is included in your 64bit library path and compile your app for 64bit.
We don''t precompile in both debug / release and 32 & 64 bit mode because it means recompiling everything 4 times while just switching your app mode & target using the components is sufficient.
TAdvOfficeButtons
TAdvOfficeRadioGroup: What is the difference between OnClick and OnCheckBoxClick
TAdvOfficeRadioGroup: What is the difference between OnClick and OnCheckBoxClick
When TAdvOfficeRadioGroup.CheckBox.Visible = true, the OnCheckBoxClick event is triggered when the caption checkbox is clicked. OnClick is the regular control's OnClick event.
TDBAdvGrid
How to format the numbers in the floatingfooter
How to format the numbers in the floatingfooter
The floatingfooter row can be treated as the last row in the grid. I.e. the format applied to the floating footer is the format of the cells at row position grid.RowCount -1.
You can use the event OnGetFloatFormat() to dynamically control this format of the last row.
TAdvSpreadGrid
How to show negative values in red within a cell with a formula
How to show negative values in red within a cell with a formula
This code snippet shows how to have negative values in red within a cell with a formula:
procedure TForm1.AdvSpreadGrid1GetCellColor(Sender: TObject; ARow, ACol: Integer; AState: TGridDrawState; ABrush: TBrush; AFont: TFont); begin if AdvSpreadGrid1.CalculatedValue[acol,arow] < 0 then AFont.Color := clred; end;
TMS FlexCel for VCL & FMX
Changing the background color of a cell in FlexCel
Changing the background color of a cell in FlexCel
It can be confusing that the code to change the background of a cell is something like:
fmt1.FillPattern.Pattern := TFlxPatternStyle.Solid; fmt1.FillPattern.FgColor := $00BCE4D8;
Why are we changing the FgColor instead of the BgColor in order to change the background color? And why does changing BgColor has no effect?
It can be a little confusing because of the names (which are the same the Excel documentation uses), but you need to understand that both FgColor and BgColor refer to the background color of a cell, and that’s why both are properties of the FillPattern. The foreground color is changed by changing the font color.
The thing is, in Excel, cells don’t need to have a solid fill, they can have a pattern fill. For example, here you have a “grid” pattern, where the foreground of the pattern is red, and the background of the pattern is yellow:
So, in FlexCel “FgColor” and “BgColor” both refer to the fill of the cell (never the foreground which as said is Font.Color). For the special case of Pattern = Solid (what we use in the 99.999% of the cases), then you set the FillPattern.Pattern to Solid, and BgColor doesn’t really matters. You can think of “Solid” as a pattern where everything is covered by the foreground color. The BgColor is still there, but not visible because FgColor covers all. If you set any other pattern than solid, you’ll see it more clearly.