Creating and Extending Windows Forms Controls

Posted July 22, 2003

Chat Date: June 24, 2003

Please note: Portions of this transcript have been edited for clarity

Chat Participants:

  • Matt Stoecker, Programmer/writer on the Visual Basic User Education team
  • Seth Grossman, Technical writer with the Windows Forms User Education Team
  • Daniel, Software Design Engineer on the Windows Forms Team
  • Jason Cooke, Programmer/writer for Visual Basic User Education
  • Subhag Oak, Software Design Engineer on Dot NET Client Team
  • Ken McGrath, TechNet/MSDN Web and Communities Producer

Moderator: Ken (Microsoft)
Welcome to today's MSDN Chat. Our topic is Creating and Extending Windows Forms Controls. Questions, comments, and suggestions are welcome. And welcome to our hosts today!

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

Host: Seth (Microsoft)
I'm Seth Grossman, a technical writer with the Windows Forms User Education Team.

Host: Daniel (Microsoft)
Hi. I am an SDE on the Windows Forms team.

Host: Jason (Microsoft)
Hi! My name is Jason Cooke, and I'm a programmer/writer for Visual Basic User Education.

Host: Soak (Microsoft)
Hi, My Name is Subhag Oak. I am SDE on Dot NET Client Team

Moderator: Ken (Microsoft)
I'm Ken McGrath, TechNet/MSDN Web and Communities Producer.

Host: Seth (Microsoft)
Q: How soon will there be a managed html browser control? When will most of the winforms controls be 100% managed and not using a wrapper?

A: So, these are sort of "hard" questions, because we can't really comment on future product plans in chats. I can say that a managed web browser control is one of the controls under evaluation by the product team. As for when there will be 100% managed controls, I don't think there's a clear picture of that yet.

Host: Matt (Microsoft)
Q: I have a custom control that implements a to custom class that inherits from basecollection. this class it has elements formed by windows controls+ string. in the control I have a property for the use of this class. if I add elements through property when I run the application I don't have anymore elements in my class

A: PG, if I understand you correctly, you're finding that collection members that you add in the designer are not persisted at run time. What you need to do is add the DesignerSerializationVisibility attribute to your property and set it to Content. As shown in this example: <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> Public Property etc. Be sure you import System.ComponentModel

Host: Daniel (Microsoft)
Q: is there a way to have the cursor show a picture in color when you are dragging and dropping?

A: Your issue with getting a color cursor, correct? If I recall the issue here is that we are calling into Ole's LoadPicture which does not support color cursors. However, there is a cursor ctor that takes an IntPtr. If you p/invoke Win32 CreateIconIndirect you can get an HCURSOR you can use to construct a color cursor.

Host: Matt (Microsoft)
Q: If I use DesignerSerializationVisibility(DesignerSerializationVisibility.visible) return a error like textbox is not makred serilizable

A: Ah. That’s a problem. The thing is, the content of your collection must be a serializable type. Since Textboxes are not serializable, you cannot persist them this way.

Host: Matt (Microsoft)
Q: Sir my question is that how can we read internet explorer links

A: Shah, I'm not 100% certain what you mean. Can you tell me what kind of scenario you're looking at here?

Host: Matt (Microsoft)
Q: What'll be the link string while it has focus

A: Are you automatic internet explorer itself, or are you using the webbrowser control?

Host: Daniel (Microsoft)
Q: Which is the correct method to hide basic property automatically added as TabStop?

A: Create a new property on your custom control with the same name. In the setter of your property, do nothing. This will prevent users from changing the property's value. To prevent the property from showing up in the PropertyGrid, add the [Browsable(false)] attribute. To prevent it from showing up in intellisense, add [EditorBrowsable(EditorBrowsableState.Never)]

Host: Matt (Microsoft)
Q: I;m automating internet explorer

A: I'm not real familiar with that scenario, but can you get a reference to the document?

Host: Matt (Microsoft)
Q: Can u answer my question ? ?

A: Shah, I'm afraid we can't. We don't have any C++ devs here at the moment and this one has us stumped. We encourage you to check out the knowledge base articles on automating internet explorer at support.microsoft.com. You may also find helpful information at msdn.microsoft.com.

Host: Daniel (Microsoft)
Q: When building controls dynamicly like in a sub before the .show of the form is used and you set the anchor and size of the control. Why does it get messed up royally I can only think it's because it's minimized when the anchor is set and the show bring brings it into windowstate normal and since the anchor was set it just mess'es it all up.

A: Without knowing the specifics of your code, its hard to say exactly what is happening. A common cause is inserting controls into a container at the positions you expect them to show up and then resizing the container before showing it which causes anchoring to reposition your controls. The workaround is to do myContainer.SuspendLayout(), insert all of your child controls, and then do a ResumeLayout( /*performLayout = */ false ); which will preserve the Size/Locations you set.

Moderator: Ken (Microsoft)
Q: Sir I have searched so much in Microsoft site and MSDN and couldn’t find helpful to my question.

A: Sorry, your question is off of today's topic and we don't have any C++ devs available right now. We are unable to answer your question. Please try reviewing some of the previous chat archives at https://msdn.microsoft.com/chats/recent.asp#vstudio.

Host: Soak (Microsoft)
Q: When using ntrol.gettype.getproperty("propertyname").setvalue(control,value,nothing) Why can't I set the numeric value instead of the type for the value object

A: When you dor a GetType.GetProperty("foo") the reflection finds the property and the type it expects. Hence the SetValue (which again finds the type by reflection) expects you to give the exact type for the property "foo" Visit https://msdn2.microsoft.com/en-us/default.aspx

https://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemTypeClassGetPropertyTopic.asp

Host: Matt (Microsoft)
Q: How to display multiple work sheets on web with office xp web component?

A: Shaorn, the topic of this chat is creating and extending windows forms controls, so this question is a little out of out area.

Moderator: Ken (Microsoft)
Thanks for joining us today and for all the great questions. It's time for us to go now. You'll be able to find the transcript of this chat soon on the MSDN Web site at <https://msdn.microsoft.com/chats/recent.asp>

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