StringGrid Part III , different ColWidth

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
olllllliii
Pro Scripter
Posts: 60
Joined: Tue Dec 22, 2009 9:51 am
Location: Mannheim ( Germany )
Contact:

StringGrid Part III , different ColWidth

Post by olllllliii » Wed Feb 20, 2013 10:30 am

Last question for Stringgridthings...i promise..:-)

i also need different colwidth for my stringgrid...
look what i mean ...

object MSStringGrid1: tMSStringGrid
Left = 8
Top = 128
Width = 1881
Height = 769
BevelKind = bkSoft
Color = 15859696
ColCount = 10
DefaultRowHeight = 30
DefaultColWidth = 150
<-- Here i need
ColWidth = {
1st row 90
2nd row 130
} and so on ...what is the command for different width ?
I am shure i have seen it elsewhere...


RowCount = 100
Font.Charset = ANSI_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Times New Roman'
Font.Style = []
GridLineWidth = 2
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing]
ParentFont = False
TabOrder = 0
end
Oliver Hilger Mannheim
alias Olllllliii

User avatar
JRL
Automation Wizard
Posts: 3497
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Wed Feb 20, 2013 2:14 pm

Last question for Stringgridthings...i promise..
Why? Every time you ask a question I learn something. Keep asking.

ColWidths rather than ColWidth

Quick addition:
For the definitions of available grid options:
http://docwiki.embarcadero.com/Librarie ... GridOption

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  Left = 511
  Top = 340
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 482
  ClientWidth = 671
  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 = 8
    Top = 128
    Width = 1881
    Height = 769
    BevelKind = bkSoft
    Color = 15859696
    ColCount = 10
    DefaultColWidth = 150
    DefaultRowHeight = 30
    RowCount = 100
    Font.Charset = ANSI_CHARSET
    Font.Color = clWindowText
    Font.Height = -16
    Font.Name = 'Times New Roman'
    Font.Style = []
    GridLineWidth = 2
    Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing]
    ParentFont = False
    TabOrder = 0
    ColWidths = (
      90
      130
      220
      150
      150
      150
      40
      150
      150
      150)
  end
end
EndDialog>Dialog1

Show>dialog1,res1
Last edited by JRL on Wed Apr 03, 2013 7:12 pm, edited 1 time in total.

olllllliii
Pro Scripter
Posts: 60
Joined: Tue Dec 22, 2009 9:51 am
Location: Mannheim ( Germany )
Contact:

Post by olllllliii » Wed Feb 20, 2013 2:18 pm

Thank you JRL...

That was what i am looking for :-)
It is a honour to learn from you !!!

Greetings from the cloudy mannheim :-)
Oliver Hilger Mannheim
alias Olllllliii

User avatar
JRL
Automation Wizard
Posts: 3497
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Wed Feb 20, 2013 2:34 pm

You're quite welcome.

Its been cloudy here in Iowa too. Expecting another snowstorm tomorrow.

Also... If you add goRowSizing, goColSizing to the StringGrid Options the user can drag the column and row borders to manually change the column and row sizes similar to Excel. Now I wonder what could be done to autosize the columns. I don't see anything that relates to that. Maybe there's a way to code it.

olllllliii
Pro Scripter
Posts: 60
Joined: Tue Dec 22, 2009 9:51 am
Location: Mannheim ( Germany )
Contact:

Post by olllllliii » Wed Feb 20, 2013 2:43 pm

I think we must write an Autosize routine... by ourself...
but i dont know how to calculate the Width for a Text in a Special Font...

Is there a Windows function that can do that ?

----> Text & Font in
<---- Pixelsize out

mhhh an l is much smaller than an M...mhhhh

After my work is done ...i will think about that...
Oliver Hilger Mannheim
alias Olllllliii

User avatar
JRL
Automation Wizard
Posts: 3497
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Wed Feb 20, 2013 3:06 pm

but i dont know how to calculate the Width for a Text in a Special Font...
I posted THIS last year. I came up with the method because I couldn't find a better way. I think it might be too slow when importing a large CSV but of course I haven't tried it yet. Hmmmm... thinking about it, only the longest string in each column would need to be tested for pixel length, height. Since text parsing has been around longer than GUIs perhaps there is a better chance of finding a method to quickly find the longest string (in characters), then test that string for size (in pixels).

I think it would be relatively simple to test the string size at the time a user is entering it so auto sizing based on user input could also be possible.

It'll be at least 12 hours before I'll have a chance to try anything like this. If you come up with something sooner, please post it.

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

Post by jpuziano » Wed Feb 20, 2013 4:53 pm

Hi olllllliii and JRL,

The ability to auto-size column width and/or height in a StringGrid object based on the data loaded would be a great feature even if its something we'd have to code ourselves.

A little Googling found the link below and even though its Delphi code, perhaps it will be helpful:

...autosize a StringGrid-Column to fit its content?
http://www.swissdelphicenter.ch/en/showcode.php?id=604
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
Grovkillen
Automation Wizard
Posts: 1009
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: StringGrid Part III , different ColWidth

Post by Grovkillen » Wed Nov 16, 2016 11:50 am

ColWidths, is it possible to change these using the SetDialogProperty>Dialog,MSStringGrid,ColWidths,Value ?

When I try nothing happens, when I try a "GetDialogProperty" nothing is returned (no such property exists).

Please advice. Thanks! :)
Let>ME=%Script%

Running: 15.0.24
version history

User avatar
JRL
Automation Wizard
Posts: 3497
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: StringGrid Part III , different ColWidth

Post by JRL » Fri Nov 18, 2016 5:10 am

Don't know what you want to do. You can set all of the columns to the same thing using:

Code: Select all

SetDialogProperty>Dialog1,MSStringGrid1,DefaultColWidth,30
Also by setting the "Options" property correctly the user can change the column size using the mouse.

User avatar
Grovkillen
Automation Wizard
Posts: 1009
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: StringGrid Part III , different ColWidth

Post by Grovkillen » Fri Nov 18, 2016 7:50 am

When I manually change the widths of the columns in the dialog designer their sizes is stored in the dialog properties but I cannot fetch them with a GetDialogProperty call, and not set them with a SetDialogProperty call...

This is found in the dialog property :

Code: Select all

ColWidths = (
      90
      130
      220
      150
      150
      150
      40
      150
      150
      150)
Let>ME=%Script%

Running: 15.0.24
version history

User avatar
Grovkillen
Automation Wizard
Posts: 1009
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: StringGrid Part III , different ColWidth

Post by Grovkillen » Mon Mar 19, 2018 5:31 pm

Markus, do you have any idea on how to set and fetch column widths?
Let>ME=%Script%

Running: 15.0.24
version history

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

Re: StringGrid Part III , different ColWidth

Post by Marcus Tettmar » Mon Mar 26, 2018 7:35 pm

Sadly I'm afraid this isn't currently possible. There is currently no way to access the column objects directly.
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
Grovkillen
Automation Wizard
Posts: 1009
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: StringGrid Part III , different ColWidth

Post by Grovkillen » Mon Mar 26, 2018 8:22 pm

All right, thanks for clearing that though.
Let>ME=%Script%

Running: 15.0.24
version history

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