Need example - Custom Dialog using new StringGrid Control

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Need example - Custom Dialog using new StringGrid Control

Post by jpuziano » Sat Feb 02, 2013 7:16 am

Hi Marcus or JRL or anyone,

Having some issues here on XP SP3. Can someone please post a working example showing how to use the new MS14 StringGrid Control on a custom dialog?

I can place the control on a Dialog but cannot seem to load it with data from a csv file.

In the Dialog Designer, I can paste a filename (and path) into the LoadFromCSV property field... but when I save the dialog, it does not create a line for that in the dialog definition.

I tried to add the line manually into the dialog definition and that did not work either, dialog then would not even show.

An example would be great - please and thanks.
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Feb 06, 2013 9:15 am

It wants raw CSV data not a file. This is so that you can get and set dynamic data. If you want to get the data from a file you would need to read in that file at run time. E.g.:

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  Left = -1154
  Top = 135
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 212
  ClientWidth = 476
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 13
  object MSStringGrid1: tMSStringGrid
    Left = 16
    Top = 14
    Width = 320
    Height = 120
    ColCount = 3
    RowCount = 1
    FixedRows = 0
    TabOrder = 8
  end
end
EndDialog>Dialog1

//if you want to get the data from a file ...
//ReadFile>c:\temp\mcsv.txt,CSVData

//or we could use a label ...

/*
CSVDataLabel:
Shape,Colour,Size
Triangle,Red,Large
Square,Blue,Small
Oval,Yellow,Medium
*/

LabelToVar>CSVDataLabel,CSVData

SetDialogProperty>Dialog1,MSStringGrid1,LoadFromCSV,CSVData

Show>Dialog1,dlgResult
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Wed Feb 06, 2013 4:23 pm

Hi Marcus,

OK, thanks for the example. So the way we use that property is via a dialog handler like this:

SetDialogProperty>Dialog1,MSStringGrid1,LoadFromCSV,CSVData

Note that with Dialog Designer open and a StringGrid object in focus, I can see the LoadFromCSV property, there is a white edit field beside it, so I typed in the following:

Shape,Colour,Size

That is raw CSV data. I saved the dialog and... nothing. Values were not saved.

My thought was, maybe I could define the values of the top row from within the dialog itself however that does not seem to work.

Of course its no big deal, we can just use a dialog handler, however maybe it would be easy enough to make it accept raw CSV data right in that field and allow us to define/save some default data within the dialog.

But if you allowed it to accept one line of raw CSV data, what about multiple lines? Maybe this introduces too many complications... so I see why you may have decided not to go that way.

OK, assuming the white edit field beside the LoadFromCSV property is NOT MEANT to ever have anything typed into it in the Dialog Designer... why is it a white edit field that you can type stuff into?

It might be best just to grey it out or... grey it out AND put some static text in there that says "for use use with dialog handler".

Just some feedback...

Many thanks for this new object by the way. I am interested in using it to quickly display data from SQL queries, perhaps allow a user to update a value somewhere in the grid and maybe save the update, or delete a row, that sort of thing.

If anyone comes up with any tricks or more in-depth StringGrid examples, please post them to the forums as right now... the example from Marcus above is the only one that exists as far as I know.

Thanks and take care
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts