Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / July 2007

Tip: Looking for answers? Try searching our database.

System.ComponentModel.Design.DesignSurface question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Matt F - 13 Jul 2007 08:21 GMT
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.
Matt F - 13 Jul 2007 08:54 GMT
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 all,
>
[quoted text clipped - 5 lines]
> solution. Any help and/or pointers in the right direction would be greatly
> appreciated.
ashokbaria@hotmail.com - 16 Jul 2007 15:30 GMT
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
Matt F - 25 Jul 2007 23:59 GMT
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
ashokbaria@hotmail.com - 16 Jul 2007 15:31 GMT
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
ashokbaria@hotmail.com - 16 Jul 2007 15:31 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.