Bonnie,
Thank you very much for your help!
>Dmitry,
>
>
>Thank you very much for the sample code.>
>You're welcome ... I like getting people started down the right path when it comes to learning this stuff.
>
>
>1. Do I understand correctly that you put the code (as in the example you kindly provided) in a .cs file of my project? Like, MyUIClasses.cs?>
>Right. I'd have a separate project for these types of classes though. So, I have a project with the namespace MyCompany.WinUI.MyBaseClasses. The rest of the WinUI part of my app might be in several projects, for example, MyCompany.WinUI.Customer and MyCompany.WinUI.Personnel.
>
>
>2. Do I then have to reference this namespace in the forms/classes where I will use them using the "using" syntax.>
>You will need to add a reference to the MyBaseClasses project under the references for the other two projects (in my example above). You really don't need to add "using" statements ... it's usually more of a convenience (I almost always do though). Typically, what the "using" statement buys you is that you can then have code like this:
>
>MyTextBox txtName = new MyTextBox();
>
>instead of this:
>
>MyCompany.WinUI.MyBaseClasses.MyTextBox txtName = new MyCompany.WinUI.MyBaseClasses.MyTextBox();
>
>
>But, it doesn't matter too much with controls that you drop on a form from the ToolBox, since the IDE always generates the code with the fully-qualified name anyway (plus, the IDE will automatically add the reference for you as well, so you typically don't even have to worry about that).
>
>~~Bonnie
>
>
>
>
>
>>Bonnie,
>>
>>Thank you very much for the sample code. Two more follow up questions, please (you are not getting rid of me easy <g>).
>>1. Do I understand correctly that you put the code (as in the example you kindly provided) in a .cs file of my project? Like, MyUIClasses.cs?
>>2. Do I then have to reference this namespace in the forms/classes where I will use them using the "using" syntax. That is, I would put the following in each class?
>>
>>using MyCompany.WinUI.MyClasses
>>
>>
>>Again, thank you.
>>
>>>Dmitry,
>>>
>>>
>Ok, Bonnie, you asked for it <g>. Watch out, here comes a very newbie question <g>. >>>
>>>LOL! No problem, Dmitry. We were all newbies at one time. <s>
>>>
>>>Here's something I've written in the past to answer this type of question. It's for WinForms, but the same applies to WebForms pretty much:
>>>
>>>Basically, you'll want a class library that contains your sub-classed UI controls, like textbox, button, etc. Something like this:
>>>
>>>using System;
>>>using System.Drawing;
>>>using System.Collections;
>>>using System.ComponentModel;
>>>using System.Windows.Forms;
>>>using System.Data;
>>>
>>>namespace MyCompany.WinUI.MyClasses
>>>{
>>> public class MyComboBox : System.Windows.Forms.ComboBox
>>> {
>>> // code here
>>> }
>>>
>>> public class MyTextBox : System.Windows.Forms.TextBox
>>> {
>>> // code here
>>> }
>>>
>>> public class MyButton : System.Windows.Forms.Button
>>> {
>>> // code here
>>> }
>>>}
>>>
>>>That's it. These controls can't be sub-classed visually, but as you can see, it's easy enough to do it in code. I have all the basic controls sub-classed in one class library file. Once they're added to the ToolBox, then can be dragged onto any design surface in the IDE.
>>>
>>>~~Bonnie
>>>
>>>
>>>
>>>>Ok, Bonnie, you asked for it <g>. Watch out, here comes a very newbie question <g>. Say, I have a web project, MyProject and I want to create my class library (I am using VFP terminology, so please forgive me) of commonly used controls (e.g dropdownlist, textbox) based on the .NET classes. What do I add to my project, a class? Or maybe you remember a thread or a link that explains how to do it?
>>>>
>>>>Thank you.
>>>>
>>>>>The cool thing is, Dmitry, is that you can start off with sub-classes with nothing in them and add the features you feel you'll need as you learn more. If you've already sub-classed your basic controls and used those sub-classed controls on your Forms already, then you'll have nothing to change when you start adding additional functionality to your sub-classes.
>>>>>
>>>>>~~Bonnie
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham