Property Grid Function

Using (or providing) Microsoft.NET Classes

Property Grid Function

Postby PGilbert on Sat Aug 07, 2010 10:34 pm

You can use the following function to find and experiment with the properties of a .Net Object:

Code: Select all
 PGRID object;form;pgrid;sink;⎕USING
⍝ Program to Show the Properties of an Object using the .Net PropertyGrid Class
⍝ http://msdn.microsoft.com/en-us/library/system.windows.forms.propertygrid.aspx
⍝ Version 1.0 - August 2010 - Pierre Gilbert

⍝ object = Valid .Net Object
⍝ PGRID∆BOUNDS = Global Variable with the Last Size and Position of the Form

 ⎕USING←'System.Windows.Forms,System.Windows.Forms.dll' 'System.Drawing,System.Drawing.dll'

 :If 9≠⎕NC'object'
     'ERROR: Argument Must be a .Net Object' ⋄ →0
 :End

⍝ Check the Global Variable 'PGRID∆BOUNDS'
 :If 0≠⎕NC'PGRID∆BOUNDS'
 :AndIf 326=⎕DR PGRID∆BOUNDS
 :AndIf '(NULL)'≢⍕PGRID∆BOUNDS
 :AndIf 'System.Drawing.Rectangle'≡PGRID∆BOUNDS.GetType.ToString
    ⍝ Do Nothing PGRID∆BOUNDS exists and is Valid
 :Else
    ⍝ First Time, set the Default Location and Size of the Form
    ⍝ Set X=60, Y=80, WIDTH=330, HEIGHT=430
     PGRID∆BOUNDS←⎕NEW Rectangle(60 80 330 430)
 :EndIf

⍝ Create the Property Grid
 pgrid←⎕NEW PropertyGrid
 pgrid.Dock←pgrid.Dock.Fill
 pgrid.SelectedObject←object

⍝ Create the Form
 form←⎕NEW Form
 form.Bounds←PGRID∆BOUNDS
 form.StartPosition←form.StartPosition.Manual
 form.FormBorderStyle←form.FormBorderStyle.SizableToolWindow
 form.Text←'Property Grid'
 form.TopMost←1
 form.Controls.Add pgrid

⍝ Show the Form and Wait on it
 form.Show ⍬
 :While form.Visible ⋄ :EndWhile

⍝ The Form is Closed

⍝ Save the Actual Location and Size of the Form
 PGRID∆BOUNDS←form.Bounds

⍝ Dispose the Form
 form.Dispose


For example if you do the following:

f←⎕new Form
PGRID f

You obtain:

PropertyGrid.png
PropertyGrid.png (22.51 KiB) Viewed 4466 times


Pierre Gilbert

P.S.: Thank to RossHale to help me finish the function
User avatar
PGilbert
 
Posts: 436
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada

Return to Microsoft.NET

Who is online

Users browsing this forum: No registered users and 1 guest