Newbie TabControl questions

Annorax

Member
Joined
Aug 31, 2007
Messages
12
Location
MA, USA
Programming Experience
1-3
Hi everyone:

I'm trying to make a tabbed Notepad like program using VB.net. With the help of lots of tutorials and code examples, I have basic tab functionality working. However, there are some things I haven't been able to figure out:

1.) How can I make double clicking on a tab close it? Is there some double click event?
2.) How can I make tabs dragable using TabControl?
3.) I have my TabControl bar but for some reason, my RichTextBox is covered by the tab bar, as in this pic:



Could someone please help me with these tasks? Thanks. :)
 
1. There is a MouseDoubleClick event, try this code:
VB.NET:
Private Sub TabControl1_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles TabControl1.MouseDoubleClick
    TabControl1.TabPages.Remove(getTabAt(TabControl1, e.Location))
End Sub

Function getTabAt(ByVal tc As TabControl, ByVal pt As Point) As TabPage
    For i As Integer = 0 To tc.TabCount - 1
        If tc.GetTabRect(i).Contains(pt) Then
            Return tc.TabPages(i)
        End If
    Next
    Return Nothing
End Function
2. See http://www.codeproject.com/useritems/DnDTabControl.asp

3. Try setting Dock=Fill for the RichTextBox control.
 
Thanks for the help, #1 and #2 work wonderfully. :)

However, I am unable to get #3 to work. I set Dock=Full for the RichTextBox but it has no affect; the tabs still partially cover the text box...
 
re:#3: Post a sample project that reproduce the problem as I can't.
 
Thanks for the assistance. I've managed to get it to work by changing Dock=Top for the TabControl. It now no longer cuts off any of the MDI child.

On somewhat of a related question, when I am typing in my RichTextBox, the vertical scrollbar does not appear if I go past the end of the window. I must change tabs and come back to the first one for it to appear. Is there some "refresh" type method I must call for this to work?
 
This is also something that works without problem here. Make sure you have latest Studio service pack (SP1). If not post a simple sample project that reproduce the problem so people see and look into the issue.
 
Back
Top