How can i change partial class name in User Control ?

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
This is the class top code:
<pre class="lang-cs prettyprint prettyprinted
Code:
<span class="com /*----------------------------------------------------------------
 * Module Name  : ListBoxControl
 * Description  : Change listBox items color
 * Author       : Danny
 * Date         : 30/12/2012
 * Revision     : 1.00
 * --------------------------------------------------------------*/<span class="pln 


using <span class="typ System<span class="pun ;<span class="pln 
using <span class="typ System<span class="pun .<span class="typ Collections<span class="pun .<span class="typ Generic<span class="pun ;<span class="pln 
using <span class="typ System<span class="pun .<span class="typ ComponentModel<span class="pun ;<span class="pln 
using <span class="typ System<span class="pun .<span class="typ Drawing<span class="pun ;<span class="pln 
using <span class="typ System<span class="pun .<span class="typ Data<span class="pun ;<span class="pln 
using <span class="typ System<span class="pun .<span class="typ Linq<span class="pun ;<span class="pln 
using <span class="typ System<span class="pun .<span class="typ Text<span class="pun ;<span class="pln 
using <span class="typ System<span class="pun .<span class="typ Windows<span class="pun .<span class="typ Forms<span class="pun ;<span class="pln 

<span class="com /*
 *  Introduction :
 * 
 *  By default the color is red.
 *  Added a property to change the color.
 *  Right mouse click on item to change item color.
 *  Left mouse click on item to change the item color back.
 *  If the listBox is empty the control will be filled with 10 "Test" items.
 * */<span class="pln 

namespace <span class="typ ListBoxControl<span class="pln 
<span class="pun {<span class="pln 
    <span class="kwd public<span class="pln  <span class="kwd partial<span class="pln  <span class="kwd class<span class="pln  <span class="typ UserControl1<span class="pln  <span class="pun :<span class="pln  <span class="typ UserControl<span class="pln 
    <span class="pun {<span class="pln 
        <span class="kwd private<span class="pln  <span class="typ Color<span class="pln  m_MyListColor<span class="pun ;<span class="pln 
        <span class="kwd private<span class="pln  <span class="typ List<span class="str <int><span class="pln  m_itemIndexes <span class="pun =<span class="pln  <span class="kwd new<span class="pln  <span class="typ List<span class="str <int><span class="pun ();<span class="pln 

        <span class="kwd public<span class="pln  <span class="typ UserControl1<span class="pun ()<span class="pln 
        <span class="pun {<span class="pln 
            <span class="typ InitializeComponent<span class="pun ();<span class="pln 

            <span class="kwd if<span class="pln  <span class="pun (<span class="pln listBox1<span class="pun .<span class="typ Items<span class="pun .<span class="typ Count<span class="pln  <span class="pun ==<span class="pln  <span class="lit 0<span class="pun )<span class="pln 
            <span class="pun {<span class="pln 
                <span class="kwd for<span class="pln  <span class="pun (<span class="typ int<span class="pln  i <span class="pun =<span class="pln  <span class="lit 0<span class="pun ;<span class="pln  i <span class="pun <<span class="pln  <span class="lit 10<span class="pun ;<span class="pln  i<span class="pun ++)<span class="pln 
                <span class="pun {<span class="pln 
                    listBox1<span class="pun .<span class="typ Items<span class="pun .<span class="typ Add<span class="pun (<span class="str "Test "<span class="pln  <span class="pun +<span class="pln  i<span class="pun );<span class="pln 
                <span class="pun }<span class="pln 
            <span class="pun }<span class="pln 
        <span class="pun }
[/code]
This project is: Windows Forms Control Library and in the project properties <br/>
is set to: class library.
So, when I compile it I have a DLL file I can add as control to the tool <br/>
box.
The first problem is how can I <br/>
change now the class name so when Im using the control instead <br/>
Code:
UserControl1
it will be for example
Code:
ListBoxControl1
or <br/>
any other name.
Second problem is that when I have the DLL file I can see the property:
<pre class="lang-cs prettyprint prettyprinted
Code:
<span class="pun [<span class="typ Browsable<span class="pun (<span class="kwd true<span class="pun )]<span class="pln 
<span class="kwd public<span class="pln  <span class="typ Color<span class="pln  <span class="typ MyListColor<span class="pln 
<span class="pun {<span class="pln 
    get <span class="pun {<span class="pln  <span class="kwd return<span class="pln  m_MyListColor<span class="pun ;<span class="pln  <span class="pun }<span class="pln 
    <span class="typ set<span class="pln 
    <span class="pun {<span class="pln 
        m_MyListColor <span class="pun =<span class="pln  value<span class="pun ;<span class="pln 
        <span class="typ Refresh<span class="pun ();<span class="pln 
    <span class="pun }<span class="pln 
<span class="pun }
[/code]
And can use it. But I cant see the <br/>
Code:
listBox1
even though I added a
Code:
listBox
control to this <br/>
User Control designer.
So, how can I make the DLL file so <br/>
if its
Code:
UserControl1
or
Code:
ListBox1
it will also have the <br/>
Code:
listBox1
inside so the user will be able to add/delete/change <br/>
item(s) to the
Code:
listBox1
?
It seems the DLL is for the User <br/>
Control only and not the
Code:
listBox1
.
The
Code:
listBox1
appears <br/>
in my run-time code of the
Code:
UserControl
but it doesnt in the DLL <br/>
file. <hr class="sig danieli

View the full article
 
Back
Top