Using Windows Forms Controls in Visual Basic .NET

Posted October 24, 2003

Chat Date: October 14, 2003

Chat Participants:

  • Robert Gruen, PSS
  • Rajesh Ganesan, WinForms SDE
  • Jim Galasyn, .NET Client UE
  • Matt Stoecker, VB.NET UE
  • Jay Allen, WinForms UE

Moderator: Ed_H (Microsoft)
Welcome to today’s chat on Using Windows Forms Controls in Visual Basic .NET. We have members of the Visual Basic team here to answer your questions today. I will ask the hosts to introduce themselves.

Host: JayAllen (Microsoft)
I'm Jay Allen, a Programmer/Writer on the Windows Forms User Education team.

Host: Jim (Microsoft)
Jim Galasyn here, and I'm a Programmer/Writer for the .NET Client User Education team.

Host: Mark (Microsoft)
Hello, my name is Mark Rideout and I'm a Program Manager in the Windows Forms team.

Host: robgruen (Microsoft)
Good afternoon, I'm Rob Gruen and I'm a support engineer for VB.NET.

Host: Matt (Microsoft)
Hi there! I'm Matt Stoecker, and I'm a programmer/writer on the Visual Basic team.

Host: Rajesh (Microsoft)
I am Rajesh Ganesan, a developer in the .Net Client team.

Moderator: Ed_H (Microsoft)
And I am Ed Hickey, VS Communities PM. Glad you all could make it today!

Moderator: Ed_H (Microsoft)
Let's get started! Fire away with your questions for our hosts.

Host: Jim (Microsoft)
Q: Evening folks, here's my question. How do I get the TabControl collection editor to use my own sub-classed TabPage class?
A: PhilC, if I understand you correctly, you'd like the Tab Page collection editor dialog to use your own derived class. Unfortunately, you'll need to write up your own design-time experience, either by creating your own UITypeEditor or by creating your own custom designer.

Host: JayAllen (Microsoft)
Q: how to do irregular form with vb .net? is there any tutorial available??
A: There's a tutorial on this available at https://msdn.microsoft.com/en-us/library/aa289517(v=vs.71).aspx.

Host: Matt (Microsoft)
Q: usually a combobox has a number of items you can select from, i want the combo box to advance to the next item automatically after i push a button
A: The following line of code will advance the selected item to the next one

Host: Matt (Microsoft)
A: ComboBox1.SelectedItem = ComboBox1.Items(ComboBox1.SelectedIndex + 1)

Host: robgruen (Microsoft)
Q: How can you color the tabs on a tabcontrol?
A: There is a backcolor property to color the tab pages, but in order to color the tabs themselves the only option available is to ownerdraw the tabs.

Host: Mark (Microsoft)
Q: Transparent controls act oddly when moving and overlapping with other controls within the same form, it seems that transparency does not take care of the z-order, and only takes care of the parent. Is that correct? Is there any solution?
A: Windows Forms controls will probably never support real transparency : they're based on HWNDs and these are opaque.

Host: Mark (Microsoft)
We simulate transparency today, but because it's not a generic solution we don't give controls the ability to do this by default. The transparency we have only paints the parent that the control is sited on, it does not deal with z-order or overlapping controls.

Host: Mark (Microsoft)
Q: It means that I can not see the control underneath, I see the Form background.
A: Yes, this is the expected behavior. We don't support true transparency for controls (non-top level.)

Host: robgruen (Microsoft)
Q: can you give a simple example how such an ownerdraw from a tab goes?
A: You can look into overriding WndProc or Paint to change the behavior of the tab control.

Host: Mark (Microsoft)
Q: Dear Mark, but this behaviour did not happen in VB6, can I use VB6 and .NET in the same application. Thank you
A: I don't recall what transparency support VB6 had, so I cannot comment on that. The VB6 forms engine and the forms engine that we use in the .NET Framework are completely different. You can use activeX controls in .NET Framework (windows forms), so try placing a VB6 active x control in windows forms and see if it still works.

Host: Rajesh (Microsoft)
Q: Are you still working on the Collection Editor question. My connection went down and I lost some of the replies?
A: Personally, I haven't done this so far, but here is something you can try:

Derive from TabControl, overload the TabPages property and specify its UITypeEditor to your own class. This class of yours can derive from System.Windows.Forms.Design.TabPageCollectionEditor.

Host: Rajesh (Microsoft)
I am not sure if this will definitely work, but it is worth a try.

Host: Rajesh (Microsoft)
Q: I hit a problem as I can't found out what base class the TabPageCollection class is derived from. The documentation just shows the interfaces.
A: PhilC, TabPageCollection just implements IList. To your TabPageCollection implementation (say MyTabPageCollection), try specifying the EditorAttribute like so:

[Editor("YourNameSpace.TabPageCollectionDerivedEditor, " + "yourassembly.dll", typeof(UITypeEditor))]

Host: Rajesh (Microsoft)
This should inform the VS designer to pick up this UITypeEditor for all properties that are of type MyTabPageCollection.

Host: Jim (Microsoft)
Q: Information can be extracted using EnumerateMetafile and EnumerateMetafileProc, but what is the information contained in the data pointer? The data does not follow EMR types described in the MSDN - Windows GDI. Where is the definition of the structures pointed by data?
A: Tur, the data contained in the EMR struct is the type of the record and its size. In managed code, this information is sent to your EnumerateMetafileProc callback in the recordType and dataSize fields.

Host: JayAllen (Microsoft)
Q: I have a doubt regarding the portability of windows forms to mobile devices.
A: We work hard to ensure the portability of Windows Forms across a variety of devices. If you have a specific issue, please let us know, and we'll do our best to resolve it.

Host: Rajesh (Microsoft)
Q: When I derive from TabControl.TabPageCollection, even though I define a constructor with 1 argument I get a compile error: something like to constructor overloads of TabControl.TabPageCollections have '0' arguments.Sorry I meant no constructure overloads ...
A: Try defining a constructor like: MyTabPageCollection(TabControl owner) and pass in the owning TabControl as the owner.

Host: Rajesh (Microsoft)
Q: That's exactly what I did. I'm wondering weather the TabPageCollection class cannot be derived from.
A: You'll have to call the base class's constructor:

class MyTabPageCollection : TabControl.TabPageCollection{ public MyTabPageCollection(TabControl owner) : base(owner) { }}

Host: Rajesh (Microsoft)
Without this explicit call, the compiler will look for the default constructor.

Moderator: Ed_H (Microsoft)
This has been a GREAT chat. Thank you to everyone. Unfortunately, it is time to go. Thanks for participating, and we'll see you next time!

For further information on this topic please visit the following:

Newsgroups: microsoft.public.dotnet.languages.vb

VB .NET Transcripts: Read the archive of past VB .NET chats.

Website: Visit the Microsoft Visual Basic .NET site.

Top of PageTop of Page