CodeConverter icon indicating copy to clipboard operation
CodeConverter copied to clipboard

C# -> VB: Form designer changes when i click a form member

Open oguzhankrcb opened this issue 5 years ago • 1 comments

Everything is okay nearly, i fixed all errors like : in "program.vb" change main private function to public method everything is okay if i dont click to form designer's member like button or form_load event when i click to form_load it doesnt look for a exist function and it creates a new function like this:

Private Sub MainForm_Load_1(sender As Object, e As EventArgs) Handles MyBase.Load

End Sub

but actually there is a method for MainForm_Load() and when i do that all other object handlers in MainForm.designer.vb are deleted.

Before i click to form element :

            ' geckobr_0
            ' 
            geckobr_0.ConsoleMessageEventReceivesConsoleLogCalls = True
            geckobr_0.Dock = System.Windows.Forms.DockStyle.Fill
            geckobr_0.FrameEventsPropagateToMainWindow = False
            geckobr_0.Location = New Drawing.Point(0, 0)
            geckobr_0.Name = "geckobr_0"
            geckobr_0.Size = New Drawing.Size(1186, 435)
            geckobr_0.TabIndex = 0
            geckobr_0.UseHttpActivityObserver = False
            AddHandler geckobr_0.DocumentCompleted, New EventHandler(Of Gecko.Events.GeckoDocumentCompletedEventArgs)(AddressOf geckobr_0_DocumentCompleted)
            AddHandler geckobr_0.ProgressChanged, New EventHandler(Of Gecko.GeckoProgressEventArgs)(AddressOf geckobr_0_ProgressChanged)
            AddHandler geckobr_0.StatusTextChanged, New EventHandler(AddressOf geckobr_0_StatusTextChanged)`

After i clicked to a form element :

            'geckobr_0
            '
            Me.geckobr_0.ConsoleMessageEventReceivesConsoleLogCalls = True
            Me.geckobr_0.Dock = System.Windows.Forms.DockStyle.Fill
            Me.geckobr_0.FrameEventsPropagateToMainWindow = False
            Me.geckobr_0.Location = New System.Drawing.Point(0, 0)
            Me.geckobr_0.Name = "geckobr_0"
            Me.geckobr_0.Size = New System.Drawing.Size(1186, 435)
            Me.geckobr_0.TabIndex = 0
            Me.geckobr_0.UseHttpActivityObserver = False`

Details

  • Product in use: VS Extension
  • Version : 8.1.5.0

oguzhankrcb avatar Jul 10 '20 13:07 oguzhankrcb

Thanks for the bug report. Generally improving the Winforms conversion is tracked as #170. For now I'll leave this open separately since it causes quite a big problem and I might be able to tackle it separately. I tackled some similar issues going VB->C# in #540, #547, #550

In order for the VB winforms code to understand, we may need to detect the AddHandler bits being generated in InitializeComponent and add them to the handling method like: geckobr_0_DocumentCompleted Handles geckobr_0.DocumentCompleted But technically that means something slightly different if someone assigns to geckobr_0. The other option is to move them out of the designer generated code so they don't get overwritten - but this would mean that clicking an object in the designer may not take you to the corresponding event handler. I think we'll need to try a few options to see what will work best

GrahamTheCoder avatar Jul 11 '20 08:07 GrahamTheCoder