Results 1 to 2 of 2

Thread: [2005] Help With VS Add-IN Updating control Text property is not applying properly

  1. #1

    Thread Starter
    Frenzied Member bmahler's Avatar
    Join Date
    Oct 2005
    Location
    Somewhere just west of the Atlantic
    Posts
    1,568

    [2005] Help With VS Add-IN Updating control Text property is not applying properly

    Ok, I am in the middle of writing an Add-IN for VS. Basically what it is is a spell checker for controls. It loops through all controls in a solution and spell checks the text in them. Well It appears to be working except that the changes are not being committed to the controls. I can visually see them change as it runs, however after closing and reopening the project none of the changes have stuck. I don't know if anyone has had any experience with creating Add-Ins and run into this, but I am pretty much at my wits end with this one. Any help would be appreciated.

    Here is some of the code

    This is the function that walks the documents
    Code:
                If IO.Path.GetExtension(fileName).ToLower = ".vb" Then
                    Dim control As System.Windows.Forms.Control = Nothing
                    Dim designerHost As System.ComponentModel.Design.IDesignerHost = Nothing
                    Dim window As EnvDTE.Window = Nothing
                    Dim wasOpen As Boolean = False
                    If _applicationObject.ItemOperations.IsFileOpen(fileName, EnvDTE.Constants.vsViewKindDesigner) Then
                        wasOpen = True
                    End If
                    window = PItem.Open(EnvDTE.Constants.vsViewKindDesigner)
                    Try
                        designerHost = CType(window.Object, System.ComponentModel.Design.IDesignerHost)
                        control = CType(designerHost.RootComponent, System.Windows.Forms.Control)
                        WalkControls(control, window)
                        window.Close(vsSaveChanges.vsSaveChangesYes)
                    Catch ex As AbortException
                        Throw
                    Catch
                        If wasOpen Then
                            window.Close(vsSaveChanges.vsSaveChangesNo)
                        End If
                    End Try
                End If
    HEre is the code that walks the controls, I have checked this and it is getting the corrected text and replacing the Control.Text with it, however as I said above, it is just not sticking.
    Code:
        Private Sub WalkControls(ByVal control As System.Windows.Forms.Control, ByVal Window As EnvDTE.Window)
            If control Is Nothing Then
                Return
            End If
            Dim replacedString As String = SpellCheckString(control.Text)
            If replacedString <> control.Text Then
                control.Text = replacedString
                Window.Document.Saved = False
            End If
            If control.Controls Is Nothing Then
                Return
            End If
            For Each subControl As System.Windows.Forms.Control In control.Controls
                WalkControls(subControl, Window)
            Next
        End Sub
    Boooya
    • Visual Studio 2008 Professional
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • Don't forget to rate helpful posts!
    • If you're question was answered please mark your thread [Resolved]


    Code Contributions:
    PHP
    PHP Image Gallery v1.0PHP Image Gallery v2.0
    VB 2005
    Find Computers on a networkSimple License EncryptionSQL Server Database Access dllUse Reflection to Return Crystal ReportDocumentSilently Print PDFGeneric Xml Serailizer


    Useful Links: (more to come)
    MSDN (The first and foremost)MSDN Design Guidelines API Reference • Inno Setup CompilerInno Setup PreprocessorISTool - Fairly easy to use GUI for creating inno setup projects • Connection StringsNAnt -Automated BuildsCruise Control .NET - Frontend for automated builds

  2. #2

    Thread Starter
    Frenzied Member bmahler's Avatar
    Join Date
    Oct 2005
    Location
    Somewhere just west of the Atlantic
    Posts
    1,568

    Re: [2005] Help With VS Add-IN

    Ok, I have done some more testing on this and found out some interesting stuff. It seems that I can change the text of the controls, however, it is not changing the text value in the Designer. Also if I move the control on the form afterwards then the changes are committed to the designer. This is weird. I am going to do some more testing with this later this evening and hopefully someone else has seen this before.
    Boooya
    • Visual Studio 2008 Professional
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • Don't forget to rate helpful posts!
    • If you're question was answered please mark your thread [Resolved]


    Code Contributions:
    PHP
    PHP Image Gallery v1.0PHP Image Gallery v2.0
    VB 2005
    Find Computers on a networkSimple License EncryptionSQL Server Database Access dllUse Reflection to Return Crystal ReportDocumentSilently Print PDFGeneric Xml Serailizer


    Useful Links: (more to come)
    MSDN (The first and foremost)MSDN Design Guidelines API Reference • Inno Setup CompilerInno Setup PreprocessorISTool - Fairly easy to use GUI for creating inno setup projects • Connection StringsNAnt -Automated BuildsCruise Control .NET - Frontend for automated builds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width