System.ComponentModel.Design.DesignSurface question

  • Thread starter Thread starter Matt F
  • Start date Start date
M

Matt F

Hi all,

In an application that has a custom form designer, via the
System.ComponentModel.Design.Design surface class, I need to be able to turn
off Snaplines, turn on the grid, set snap to grid etc. In searching around
I've found a number of references so the DesignerOptionService but the
documentation that I can find is not quite getting me to the final solution.
Any help and/or pointers in the right direction would be greatly
appreciated.
 
Please disregard this --- the issue has been solved.

It was simply a matter of how I was declaring the service. One of those
times when you spend far too long looking at an issue and get too close to
it to see the problem --- of course I found the solution five minutes after
posting.
 
Hi Matt F,
In an application that has a custom form designer, via the
System.ComponentModel.Design.Design surface class, I need to be able to turn
off Snaplines, turn on the grid, set snap to grid etc. In searching around
I've found a number of references so the DesignerOptionService but the
documentation that I can find is not quite getting me to the final solution.
Any help and/or pointers in the right direction would be greatly
appreciated.

I have the same problem, can you please provide me some code or example on how resolved this issue.

Thanks
 
Hi Matt F,
In an application that has a custom form designer, via the
System.ComponentModel.Design.Design surface class, I need to be able to turn
off Snaplines, turn on the grid, set snap to grid etc. In searching around
I've found a number of references so the DesignerOptionService but the
documentation that I can find is not quite getting me to the final solution.
Any help and/or pointers in the right direction would be greatly
appreciated.

I have the same problem, can you please provide me some code or example on how resolved this issue.

Thanks
 
Hi Matt F,
In an application that has a custom form designer, via the
System.ComponentModel.Design.Design surface class, I need to be able to turn
off Snaplines, turn on the grid, set snap to grid etc.

I have the same problem, can you please provide me some code or example on how resolved this issue.

Thanks
 
Sorry for the delay in getting this to you --- I've gotten pulled off to
another project, and haven't checked the groups for a while.

That being said, the following code needs a lot of cleanup (haven't gotten
back to it since asking the ?) but it should get you going in the right
direction.

The issue that I was having after creating the class was how I was declaring
it --- it's a little obtuse --- here is a snippet that shows the declaration
code that works:
(sorry my newgroup reader is really screwing up the formatting here, but if
you paste to VS it should fix it for you)
Imports System.ComponentModel.Design

Imports System.Windows.Forms

Public Class MyDesignSurface

Inherits DesignSurface

Private mHost As IDesignerHost

Private mDesignerOptionService As DesignerOptionService

Sub New()

MyBase.New()

mHost = DirectCast(Me.GetService(GetType(IDesignerHost)), IDesignerHost)


' set up the designer option service

mDesignerOptionService = New MyDesignerOptionService

MyServiceContainer.AddService(GetType(DesignerOptionService),
mDesignerOptionService)

End Sub



Without further delay here is the DesignerOptionService class!!! (yeah, it's
ugly and needs tons of work, but will help get you going in right direction)
Imports System.ComponentModel.Design

#Region " Snapline stuff "

Class MyDesignerOptionService

Inherits DesignerOptionService

Public Sub New()

End Sub

'/ <summary>

'/ Populates an option collection with the settings for the DesignSurface.

'/ </summary>

'/ <param name="options"></param>

Protected Overrides Sub PopulateOptionCollection(ByVal options As
DesignerOptionCollection)

If options.Parent Is Nothing Then

Dim opt As Windows.Forms.Design.DesignerOptions = New
Windows.Forms.Design.DesignerOptions()

'opt.UseSmartTags = True

opt.UseSnapLines = False

opt.SnapToGrid = True

opt.ShowGrid = True

'opt.ObjectBoundSmartTagAutoShow = True

Dim wfdc As DesignerOptionCollection = Me.CreateOptionCollection(options,
"WindowsFormsDesigner", Nothing)

Dim wfdgc As DesignerOptionCollection = Me.CreateOptionCollection(wfdc,
"General", opt)

End If

End Sub

End Class

#End Region
 
Back
Top