Inheriting from controls 
Author Message
 Inheriting from controls

Hi All,

That is pretty strange for me that I this time I could not find my answer in
any newsletter or forum or anywhere on the net. Here is the problem:

I would like to do a very simple task; inherit from a combobox and load a
list of operators from a table on a SQL database when form loads.
I put loading code in constructor:

 Public Class DclUsersCombo
    Inherits ComboBox

   Public Sub New()

      MyBase.New()
      Me.DataSource = DclSecurity.GetDclOperatorList() ' returns an
arraylist of operators

    End Sub

But the problem was that when I added the control to a form, VS.NET behind
the scene reads from the database and on InitializeComponent, adds list of
operators as an arraylist, so I will have the list but reading offline from
persisted arraylist:

    Me.DclUsersCombo1.DataSource =
CType(resources.GetObject("DclUsersCombo1.DataSource"),
System.Collections.ArrayList)
    Me.DclUsersCombo1.Items.AddRange(New Object() {"Ali Kheyrollahi", "John
Doe", ..., "Someone Whoever" })

I was also unable to find a suitable "loading" event for control. Also
checking if control is at design-time did not help.

What should I do?

Many Thanks in advance
Ali Kheyrollahi



Sat, 17 Sep 2005 16:50:59 GMT  
 Inheriting from controls
Let me restate the problem:

I can use OnCreateHandle but why OnPaint cannot be overriden? I mean I
override it but it is never fired!!

Thanks
Ali


Quote:
> Hi All,

> That is pretty strange for me that I this time I could not find my answer
in
> any newsletter or forum or anywhere on the net. Here is the problem:

> I would like to do a very simple task; inherit from a combobox and load a
> list of operators from a table on a SQL database when form loads.
> I put loading code in constructor:

>  Public Class DclUsersCombo
>     Inherits ComboBox

>    Public Sub New()

>       MyBase.New()
>       Me.DataSource = DclSecurity.GetDclOperatorList() ' returns an
> arraylist of operators

>     End Sub

> But the problem was that when I added the control to a form, VS.NET behind
> the scene reads from the database and on InitializeComponent, adds list of
> operators as an arraylist, so I will have the list but reading offline
from
> persisted arraylist:

>     Me.DclUsersCombo1.DataSource =
> CType(resources.GetObject("DclUsersCombo1.DataSource"),
> System.Collections.ArrayList)
>     Me.DclUsersCombo1.Items.AddRange(New Object() {"Ali Kheyrollahi",
"John
> Doe", ..., "Someone Whoever" })

> I was also unable to find a suitable "loading" event for control. Also
> checking if control is at design-time did not help.

> What should I do?

> Many Thanks in advance
> Ali Kheyrollahi



Sat, 17 Sep 2005 18:07:44 GMT  
 Inheriting from controls
Hi Ali, You shouldn't override the OnPaint event because that gets fired a
lot, depending on the drawing state of the control.

--
Remember: There's no place like 127.0.0.1
==============================================
Happy To Help,
Tom Spink

http://dotnetx.betasafe.com >> VB, VB.NET, C#, C++ Code
Happy Coding!!

Please respond to the newsgroups, so all can benefit.

One day

Quote:
> Let me restate the problem:

> I can use OnCreateHandle but why OnPaint cannot be overriden? I mean I
> override it but it is never fired!!

> Thanks
> Ali



> > Hi All,

> > That is pretty strange for me that I this time I could not find my
answer
> in
> > any newsletter or forum or anywhere on the net. Here is the problem:

> > I would like to do a very simple task; inherit from a combobox and load
a
> > list of operators from a table on a SQL database when form loads.
> > I put loading code in constructor:

> >  Public Class DclUsersCombo
> >     Inherits ComboBox

> >    Public Sub New()

> >       MyBase.New()
> >       Me.DataSource = DclSecurity.GetDclOperatorList() ' returns an
> > arraylist of operators

> >     End Sub

> > But the problem was that when I added the control to a form, VS.NET
behind
> > the scene reads from the database and on InitializeComponent, adds list
of
> > operators as an arraylist, so I will have the list but reading offline
> from
> > persisted arraylist:

> >     Me.DclUsersCombo1.DataSource =
> > CType(resources.GetObject("DclUsersCombo1.DataSource"),
> > System.Collections.ArrayList)
> >     Me.DclUsersCombo1.Items.AddRange(New Object() {"Ali Kheyrollahi",
> "John
> > Doe", ..., "Someone Whoever" })

> > I was also unable to find a suitable "loading" event for control. Also
> > checking if control is at design-time did not help.

> > What should I do?

> > Many Thanks in advance
> > Ali Kheyrollahi



Sun, 18 Sep 2005 01:27:36 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Controls Inheriting Other Control's Properties

2. Controls Inheriting Other Control's Properties

3. Controls Inheriting Other Control's Properties

4. Controls Inheriting Other Control's Properties

5. Inherits - TreeNode Control

6. Creating/Inheriting WinForm controls

7. Inheriting TextBox control

8. Creating/Inheriting WinForm controls

9. Custom Painting in an inherited textbox control

10. Custom Inherited User Control Doesn't Show Up in Toolbox

11. custom form control: Cannot view design view of forms that inherit this form

12. Tab Control in inherited forms

 

 
Powered by phpBB® Forum Software