[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 358
  • Last Modified:

How do I change the Drag-Once label type for databinding in the Windows Forms designer?

I use C# and Winforms for many projects.  I usually databind to my business objects.  I have my own and 3rd party controls that I bind to.  I changed/added the custom controls to the associated datatypes with no problems.  Now when I drag out an object property from the data sources window it gives me my bound custom control and a System.Windows.Forms.Label control.  I want to replace the label with my own type.  I cannot find anywhere to set this.  I should be able to be changed I would think.  Anyone know if it is possible?

Ex.

Default (No Custom Controls)
----------------------------------------------------------------------
CustomerEntity.Name:
        System.Windows.Forms.Label nameLabel;
        System.Windows.Forms.TextBox nameTextBox;

Current (With Custom Controls)
-----------------------------------------------------------------------
CustomerEntity.Name:
        System.Windows.Forms.Label nameLabel;
        Custom.Windows.Forms.MyTextBox nameMyTextBox;

Wanted
--------------------------------------------------------------------------
CustomerEntity.Name:
        Custom.Windows.Forms.MyLabel nameMyLabel;
        Custom.Windows.Forms.MyTextBox nameMyTextBox;
0
jeshbr
Asked:
jeshbr
  • 9
  • 8
1 Solution
 
Bob LearnedCommented:
Are you talking about the Data UI Customization options available through Tools | Options?
Data-UI-Customization-Options.png
0
 
jeshbrAuthor Commented:
That is set correctly.
The actual bound control is created correctly.
I drag out a string value and I get a MyTextBox control but it also creates a System.Windows.Forms.Label.  
I have to manually delete the label and add my MyLabel control.  
Its not the end of the world but it sure takes more time than I want to take.
0
 
Bob LearnedCommented:
Do you have multiple controls selected for the String data type?
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
jeshbrAuthor Commented:
Yes. I have many.  There are no System.Windows.Forms control in the list. They are all custom or 3rd party.
0
 
Bob LearnedCommented:
What is the base class for MyTextBox?
0
 
jeshbrAuthor Commented:
Its a KryptonTextBox from Component Factory's Krypton Toolkit.
0
 
Bob LearnedCommented:
Can you show me the Data UI Customization options for the String value, please?
0
 
jeshbrAuthor Commented:
I was only using MyTextBox as an example my actual control namespace is MSF.Windows.Forms.
The full name of the TextBox is MSF.Windows.Forms.Text but it is wrapping a KryptonTextBox.
DataUICustomizationSP.GIF
0
 
Bob LearnedCommented:
I still see Label, LinkLabel, CheckBox, CheckedListBox, ComboBox items checked, which look like Windows Forms controls to me.  What happens if you uncheck the Label option?
0
 
jeshbrAuthor Commented:
I removed them and it didn't make any difference.
I wrap all the controls that I use and put them in my own namespace.
All of the controls you see checked are in MSF.Windows.Forms.
Most of them are wrapped Krypton controls.

Do you not have this problem?
Maybe I need to reinstall VS 2008?
0
 
Bob LearnedCommented:
I just downloaded the Krypton Toolkit from Component Factory, so that I can verify.  

What operating system is this running on?  Are there any service packs installed?  I am running 2008 SP1 on Windows XP Professional SP2.
0
 
jeshbrAuthor Commented:
I am running 2008 SP1 on XP Pro SP3.
I wouldn't think SP3 would have anything to do with it.
0
 
Bob LearnedCommented:
I never use that Data UI Customization, so I hadn't seen the problem that you described, but I was able to duplicate it, so it appears to be a standard implementation for VS.NET to add a Label control.  I haven't discovered any way, yet, to control that control type.
0
 
Bob LearnedCommented:
I know that it is pretty easy to change the Label controls to MyLabel controls without having to delete the controls, and recreate them.  You can open the .designer file associated with that form, and expand the "Windows Form Designer generated code" region, and replace the System.Windows.Forms.Label with MSF.Windows.Forms.MyLabel.


       #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
            System.Windows.Forms.Label lastNameLabel;
 
...

Open in new window

0
 
jeshbrAuthor Commented:
Yeah.
I just use a Find/Replace after I am done adding all my controls but its a pain and I hate messing with the designer code.
I guess I will just have to live with it.
0
 
Bob LearnedCommented:
I feel your pain.  I even looked through the Registry for an undocumented setting that might control that.  
0
 
jeshbrAuthor Commented:
Thanks.  I appreciate your help.
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

  • 9
  • 8
Tackle projects and never again get stuck behind a technical roadblock.
Join Now