Problem with TabControl

some buddy

Member
Joined
Sep 28, 2009
Messages
9
Location
Montreal
Programming Experience
Beginner
Hi,

I've tried to integrate recently two small GUI applications in one single GUI. Being both about text, I've decided to add a TabControl with two pages on the first one, then to keep the first application on TabPage1 and to implement the second one's controls on TabPaget2. I thought that I could just copy the controls of the applications and paste them on the new TabControl on the corresponding TabPage, but then I've discovered that after the copy-paste, the controls stopped responding, like because they are behind this TabControl which acts like a "shield", the controls can not "see" the code anymore:mad:

For better understanding, there are two attached screen shots, the GUI of the first application before implementing the TabControl and after. I would mention that both utilities were functional before implementing the TabControl, although I didn't continue with the implementation of the second one :(

My question is if somebody could give me a hint of what should I do in order to make the controls work again in this new configuration, with the TabControl.

TIA
 

Attachments

  • before.jpg
    before.jpg
    18.7 KB · Views: 23
  • after.jpg
    after.jpg
    18.8 KB · Views: 24
Did you copy the code too? or just the controls on the form? I've only ever had this happen to me when I copied the controls but forgot to copy the code for them too.
 
No need to copy the code because it is there, this is the original application, the TabControl was added there, only the controls were transfered to the TabControl.

Let's put it this way:

I have an working application with a GUI. For some reason I need to add a TabControl. So I've added the TabControl and transferred the controls usinf copy-paste, without any modification to the associated code. Then the application stops working.

Hope I made myself clear.
 
Check to make sure the Handles clause is still at the end of the events. Even if the code is still there it will not function without this.
 
Although I don't know what you mean (I am a beginner and the application was a free one and came with the source code) I don't see why it shouldn't be there, because I didn't touch the code. I've just selected all the controls with the mouse, then Ctrl+C to clipboard, added the TabContrl and then Ctrl+V on the TabControl.

Although I am a novice, I mov every carefully through the code because I know that if I mess it, I won't be able to fix it back : )

My purpose is to learn more. Actually I have the code for the TabPage2 and it works without the GUI and I want to understand how to build the GUI on the TabPage2 for the second application.
 
It has to do with you cutting the controls and pasting them, the IDE will strip this part off. This is why i ask you to check for this. The events are things like; button1_Click, textbox1_TextChanged, etc... At the end of each of these subs is a Handles clause. These are the sub routines that make things happen i.e. the code that is not working anymore. So if any of these are missing the Handles clause they won't work/do something.

Example:
VB.NET:
Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button1.Click '<- this part
'code goes here
End Sub
 
Yes, these are there, I checked them instinctively, without knowing they are called "Handles clause" (LOL):

Private Sub btnReplace_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

'Me.statusText.Text = "Getting text..."
Call DisableUI()

GetAllTextWorker.RunWorkerAsync()

End Sub

Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
If GetAllTextWorker.IsBusy Then
GetAllTextWorker.CancelAsync()
End If
If ReplaceTextWorker.IsBusy Then
ReplaceTextWorker.CancelAsync()
End If
Me.DialogResult = Windows.Forms.DialogResult.Cancel
Me.Hide()
End Sub
 
Sorry, I think it should be like this:

VB.NET:
Private Sub btnReplace_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

        'Me.statusText.Text = "Getting text..."
        Call DisableUI()

        GetAllTextWorker.RunWorkerAsync()

End Sub

Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

        If GetAllTextWorker.IsBusy Then
            GetAllTextWorker.CancelAsync()
        End If

        If ReplaceTextWorker.IsBusy Then
            ReplaceTextWorker.CancelAsync()
        End If

        Me.DialogResult = Windows.Forms.DialogResult.Cancel

        Me.Hide()
End Sub
 
As NewGuy pointed out, you are missing the event handlers

VB.NET:
    Private Sub btnReplace_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) [COLOR="red"][B]Handles btnReplace.Click[/B][/COLOR]

        'Me.statusText.Text = "Getting text..."
        Call DisableUI()

        GetAllTextWorker.RunWorkerAsync()

    End Sub

VB.NET:
    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) [COLOR="Red"][B]Handles btnCancel.Click[/B][/COLOR]
        If GetAllTextWorker.IsBusy Then
            GetAllTextWorker.CancelAsync()
        End If
        If ReplaceTextWorker.IsBusy Then
            ReplaceTextWorker.CancelAsync()
        End If
        Me.DialogResult = Windows.Forms.DialogResult.Cancel
        Me.Hide()
    End Sub
 
Oooooh, I see, I thought that these at the end of the function declaration, were his comments...

Well, I am sorry, I think that this is what happens when you are a beginner, i.e. looking stupid : ) I have some experience with VBA and VB, but there were no clauses : )

Thanks guys.
 
Last edited:
Back
Top