Frequently Asked Component Specific Questions
Displaying items 1 to 15 of 479, page 1 of 32
<< previous next >>

TMS Advanced Dropdown Controls: How to setup a default TAdvColumnGrid with 2 columns, data for columns and retrieve selected value & index
(Sep 1, 2012)
This code snippet shows how to setup a default TAdvColumnGrid with 2 columns, data for columns and retrieve selected value & index:
procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage( IntToStr(AdvMultiColumnDropDown1.ItemIndex) + ':'+ AdvMultiColumnDropDown1.Text);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
AdvMultiColumnDropDown1.Columns.Clear;
AdvMultiColumnDropDown1.Columns.Add;
AdvMultiColumnDropDown1.Columns.Add;
AdvMultiColumnDropDown1.Columns[0].Header := 'Col 1';
AdvMultiColumnDropDown1.Columns[1].Header := 'Col 2';
AdvMultiColumnDropDown1.Items.Clear;
AdvMultiColumnDropDown1.Items.Add.Text.CommaText := 'A,1';
AdvMultiColumnDropDown1.Items.Add.Text.CommaText := 'B,2';
AdvMultiColumnDropDown1.Items.Add.Text.CommaText := 'C,3';
AdvMultiColumnDropDown1.Items.Add.Text.CommaText := 'D,4';
end;
Result:

Nancy Lescouhier (Sep 1, 2012)


THTMLTreeView: How to have all Child items checked or unchecked depending on the parent check state
(Mar 2, 2012)
This is a code snippet that demonstrates this applied to a default THTMLTreeView on the form:
procedure TForm4.FormCreate(Sender: TObject);
var
tn,sn: TTreeNode;
begin
tn := htmltreeview1.Items.Add(nil,'Parent node');
htmltreeview1.SetNodeCheck(tn, false);
sn := htmltreeview1.Items.AddChild(tn,'Child 1');
htmltreeview1.SetNodeCheck(sn, false);
sn := htmltreeview1.Items.AddChild(tn,'Child 2');
htmltreeview1.SetNodeCheck(sn, false);
sn := htmltreeview1.Items.AddChild(tn,'Child 3');
htmltreeview1.SetNodeCheck(sn, false);
tn := htmltreeview1.Items.Add(nil,'Parent node');
htmltreeview1.SetNodeCheck(tn, false);
end;
procedure TForm4.HTMLTreeview1CheckBoxClick(Sender: TObject; Node: TTreeNode; Check: Boolean);
var
i: integer;
sn: TTreeNode;
begin
sn := Node.getFirstChild;
while assigned(sn) do
begin
Htmltreeview1.SetNodeCheck(sn,check);
sn :=sn.getNextSibling;
end;
end;
Results in:

Nancy Lescouhier (Mar 2, 2012)


TMS FlexCel Studio for .NET: How to autofit merged cells
(Mar 2, 2012)


TDBAdvGrid: Images that are stored in BLOB fields are displayed as '(GRAPHIC)‘
(Feb 1, 2012)
Please make sure that:
1) the field’s datatype is ftBlob
2) DBAdvGrid.ShowPictureFields = true
3) DBAdvGrid.Columns[columnindex].PictureField = true , for the column where the blob is to be displayed
This is also explained at page 191 of the
TMS Grid Pack Developers Guide.
Nancy Lescouhier (Feb 1, 2012)


TMS FlexCel Studio for VCL: How to add a new sheet to an excel file
(Jan 30, 2012)
You can call FlexCelImport.InsertEmptySheets to add new sheets.
To insert a new sheet as a last sheet, just call:
FlexCelImport.InsetEmptySheets(FlexCelImport.Sheetcount + 1, 1);
Nancy Lescouhier (Jan 30, 2012)


TDBAdvListView: Sorting
(Jan 26, 2012)
When HeaderFlatStyle = true, the listview header becomes by design non clickable, hence, it will not
register a click to start the sorting. When HeaderFlatStyle = false, the header can be clicked and can
show a down effect when the mouse is down on the header. In this situation, it registers the mouseclick
and can perform the sort.
Nancy Lescouhier (Jan 26, 2012)


TAdvStringGrid: How to make certain columns editable
(Jan 26, 2012)
Please set goEditing = true and do this with the event OnCanEditCell:
procedure TForm4.AdvStringGrid1CanEditCell(Sender: TObject; ARow, ACol:Integer; var CanEdit: boolean);
begin
CanEdit := ACol = 1;
end;
Nancy Lescouhier (Jan 26, 2012)


TDBAdvCardList: How to custom draw an image
(Jan 24, 2012)
You'd need to do this using the event: OnDrawCardItem:
procedure TForm4.AdvCardList1DrawCardItem(Sender: TObject; Card: TAdvCard;
Item: TAdvCardItem; Canvas: TCanvas; Rect: TRect);
begin
end;
This event returns the card & item that should be drawn and from this event, you'd need to perform the drawing in the Canvas passed as parameter and rectangle Rect, ie. something like:
procedure TForm4.AdvCardList1DrawCardItem(Sender: TObject; Card: TAdvCard;
Item: TAdvCardItem; Canvas: TCanvas; Rect: TRect);
begin
imagelist1.Draw(rect.Left,rect.Top, item.Tag);
end;
if you'd have stored the index of an imagelist image in the item's Tag property.
Nancy Lescouhier (Jan 24, 2012)


TAdvStringGrid: How to turn off the gradient and override the fixed column color
(Jan 24, 2012)
This code snippet shows how you can turn off the gradient and override the fixed column color:
procedure TForm4.AdvStringGrid1GetCellColor(Sender: TObject; ARow,
ACol: Integer; AState: TGridDrawState; ABrush: TBrush; AFont: TFont);
begin
if Acol = 0 then
ABrush.Color := clRed;
end;
procedure TForm4.FormCreate(Sender: TObject);
begin
advstringgrid1.look :=glSoft;
end;
Nancy Lescouhier (Jan 24, 2012)


TPlanner: How to create a new PlannerItem when clicking on an empty cell
(Jan 24, 2012)
If Planner.AutoInsDel = true, the OnItemInsert event should be triggered.
When Planner.AutoInsDel = false, you need to programmatically create the item with Planner.CreateItem
This is also described in the Planner
PDF developers guide.
Nancy Lescouhier (Jan 24, 2012)


TAdvStringGrid: How to add a sheet to an existing Excel workbook using AdvGridExcelIO.XLSExport
(Jan 20, 2012)
The 2nd parameter of the XLSExport() call is the sheetname. You can specify a new sheet name, a sheet name different from the default sheetname and it will save the data in the specified sheet.
Nancy Lescouhier (Jan 20, 2012)


TMS WebGMaps: How to convert an address to a longitude, latitude coordinate
(Jan 13, 2012)
The TWebGMapsGeocoding component is a helper component to enable using the Google geocoding
service to convert an address to a longitude, latitude coordinate. Set the address: STREET (NUMBER), (ZIPCODE) CITY, COUNTRY ,
and call the function TWebGMapsGeocoding.LaunchGeocoding. When the result of this call is erOK,
the geocoding was successful and the longitude & latitude for the address can be read from:
TWebGMapsGeocoding.ResultLatitude
TWebGMapsGeocoding.ResultLongitude
Example:
WebGMapsGeocoding1.Address := 'Broadway 615, LOS ANGELES, USA';
if WebGMapsGeocoding1.LaunchGeocoding = erOk then
begin
ShowMessage(‘Result:’+ FloatToStr(WebGMapsGeocoding1.ResultLongitude)+’:’+ loatToStr(WebGMapsGeocoding1.ResultLatitude));
end;
Nancy Lescouhier (Jan 13, 2012)


TMS WebGMaps: Getting started
(Jan 13, 2012)
From the component palette, select TWebGMaps and drop it on a form. This shows an empty map.
The map is only displayed when WebGMaps.Launch is called. The default center location displayed
when WebGMaps.Launch is called is set by:
WebGMaps.MapOptions.DefaultLongitude
WebGMaps.MapOptions.DefaultLatitude
Markers can be added to the map by adding a new entry to the collection WebGMaps.Markers and
setting the Marker’s properties Longitude & Latitude.
This code snippet sets up the default view of the TWebGMaps to show the Los Angeles Theatre on
Broadway at zoom level 19 with coordinates retrieved from the TWebGMapsGeocoding component:
begin
WebGMapsGeocoding1.Address := 'Broadway 615, LOS ANGELES, USA';
if WebGMapsGeocoding1.LaunchGeocoding = erOk then
begin
// center the map at the coordinate
WebGMaps1.MapOptions.DefaultLatitude := WebGMapsGeocoding1.ResultLatitude;
WebGMaps1.MapOptions.DefaultLongitude := WebGMapsGeocoding1.ResultLongitude;
// Add a marker for the Los Angeles theatre
WebGmaps1.Markers.Add(WebGMapsGeocoding1.ResultLatitude,
WebGMapsGeocoding1.ResultLongitude,'Broadway theatre');
// set zoom level
WebGmaps1.MapOptions.ZoomMap := 19;
// launch the display of the map
WebGMaps1.Launch;
end;
end;
Further to this, we can take a look at the Los Angeles theatre by switching the map to StreetView.
Following code snippet makes this switch when a checkbox is clicked:
procedure TForm1.CheckBox1Click(Sender: TObject);
begin
if checkbox1.Checked then
WebGmaps1.SwitchToStreetView
else
WebGmaps1.SwitchToMap;
end;

Nancy Lescouhier (Jan 13, 2012)


TAdvStringGrid: Copy a row with cell values & properties from one grid to another grid
(Jan 1, 2012)
This code snippet that can be applied to two default TAdvStringGrid instances shows how all cell values & cell properties within a rectangle can be copied from one grid to another grid via a memory stream:
procedure TForm4.FormCreate(Sender: TObject);
var
st: TMemoryStream;
begin
advstringgrid1.Colors[1,1] := clred;
advstringgrid1.Colors[2,1] := clYellow;
advstringgrid1.RandomFill(false,100);
st := TMemoryStream.Create;
try
advstringgrid1.SaveRectToBinStream(Rect(0,1,advstringgrid1.ColCount - 1, 1), st);
st.Position := 0;
advstringgrid2.LoadAtPointFromBinStream(Point(0,1),st);
finally
st.Free;
end;
end;
Bruno Fierens (Jan 1, 2012)


TMS HTML Controls Pack: How to use the design-time mini HTML editor at run-time
(Jan 1, 2012)
You can easily use the mini HTML design-time editor at run-time to allow users to edit the mini-HTML controls text at run-time. To allow this, use following steps : add the HTMLPROP unit to your project and add HTMLPROP to the uses clause in the unit from where you want to invoke the mini HTML editor. Add the following code to allow for example run-time editing of the content of a HTMLabel1 component :
var
htmledit: THTMLEditor;
begin
htmledit := THTMLEditor.Create(Self);
try
htmledit.memo1.lines.Text := htmlabel1.htmltext.Text;
htmledit.ShowModal;
htmlabel1.htmltext.Text := htmledit.memo1.lines.Text;
finally
htmledit.Free;
end;
end;
Bruno Fierens (Jan 1, 2012)