Click here to Skip to main content
15,920,053 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: TERMINAL SERVICE CONTROL IN VB.6 Pin
Steven J Jowett10-Feb-09 23:57
Steven J Jowett10-Feb-09 23:57 
AnswerRe: TERMINAL SERVICE CONTROL IN VB.6 Pin
Smithers-Jones11-Feb-09 1:13
Smithers-Jones11-Feb-09 1:13 
QuestionSynchronizaiton (Multithreading) Pin
Muhammad Fahim Baloch10-Feb-09 20:26
Muhammad Fahim Baloch10-Feb-09 20:26 
AnswerRe: Synchronizaiton (Multithreading) Pin
Dave Kreskowiak11-Feb-09 1:33
mveDave Kreskowiak11-Feb-09 1:33 
AnswerRe: Synchronizaiton (Multithreading) Pin
Ashfield11-Feb-09 1:33
Ashfield11-Feb-09 1:33 
QuestionSmall Issue, Needs Urgent help Pin
shawndeprey10-Feb-09 10:16
shawndeprey10-Feb-09 10:16 
AnswerRe: Small Issue, Needs Urgent help Pin
Christian Graus10-Feb-09 12:49
protectorChristian Graus10-Feb-09 12:49 
GeneralRe: Small Issue, Needs Urgent help Pin
shawndeprey10-Feb-09 14:52
shawndeprey10-Feb-09 14:52 
AnswerRe: Small Issue, Needs Urgent help Pin
Fernando Soto10-Feb-09 17:37
Fernando Soto10-Feb-09 17:37 
GeneralRe: Small Issue, Needs Urgent help Pin
shawndeprey11-Feb-09 13:38
shawndeprey11-Feb-09 13:38 
GeneralRe: Small Issue, Needs Urgent help Pin
Fernando Soto11-Feb-09 16:22
Fernando Soto11-Feb-09 16:22 
Question[Message Deleted] Pin
JUNEYT10-Feb-09 6:15
JUNEYT10-Feb-09 6:15 
GeneralRe: Why do I get "System.ArgumentOutOfRangeException" for recently added columns to listview? Pin
Luc Pattyn10-Feb-09 6:27
sitebuilderLuc Pattyn10-Feb-09 6:27 
AnswerRe: Why do I get "System.ArgumentOutOfRangeException" for recently added columns to listview? Pin
Dave Kreskowiak10-Feb-09 6:36
mveDave Kreskowiak10-Feb-09 6:36 
RantRe: [Message Deleted] Pin
Smithers-Jones10-Feb-09 7:21
Smithers-Jones10-Feb-09 7:21 
Questionimages/photos/pictures Pin
ngugi10-Feb-09 5:42
ngugi10-Feb-09 5:42 
AnswerRe: images/photos/pictures Pin
Henry Minute10-Feb-09 6:19
Henry Minute10-Feb-09 6:19 
AnswerRe: images/photos/pictures Pin
Dave Kreskowiak10-Feb-09 6:34
mveDave Kreskowiak10-Feb-09 6:34 
QuestionAdding a control from within a class Pin
Paul Hasler10-Feb-09 4:16
Paul Hasler10-Feb-09 4:16 
This is a bit of a Newbie question... Blush | :O

I am trying to write a class which adds a control to it's host, where the host could be any suitable container such as a Panel, GroupBox, or a Form.

I know I can add a control directly to a Form for example in the following way:

   Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)_
Handles MyBase.Load
       Dim myControl As New SomeControl

       With myControl
           .Left = myLeft
           .Top = myTop
           .Width = myWidth
           .Height = myHeight
           .Visible = True
       End With

       Me.Controls.Add(myControl)

   End Sub


But I'm having trouble doing it from within a class.

   Public Class MyNewClass
    .
    .
    .
    Public Sub New(ByVal newLeft As Short, ByVal newRight As Short, ByVal newWidth As Short,_
ByVal newHeight As Short)
       myLeft = newLeft
       myRight = newRight
       myWidth = newWidth
       myHeight = newHeight

       Dim myControl As New SomeControl

       With myControl
           .Left = myLeft
           .Top = myTop
           .Width = myWidth
           .Height = myHeight
           .Visible = True
       End With

       Me.Controls.Add(myControl)

    End Sub


Clearly "Me" now refers to the instance of MyNewClass and not the Container or Form in which it is intended to go, so it's not going to work. Frown | :(

How should I do it?

Thanks in advance.
AnswerRe: Adding a control from within a class Pin
JoeSharp10-Feb-09 4:30
JoeSharp10-Feb-09 4:30 
GeneralRe: Adding a control from within a class Pin
Jon_Boy10-Feb-09 5:31
Jon_Boy10-Feb-09 5:31 
AnswerRe: Adding a control from within a class Pin
Dave Kreskowiak10-Feb-09 6:33
mveDave Kreskowiak10-Feb-09 6:33 
AnswerRe: Adding a control from within a class Pin
Paul Hasler10-Feb-09 11:47
Paul Hasler10-Feb-09 11:47 
QuestionTwo questions regarding custom user controls and the toolbox. Pin
Jon_Boy10-Feb-09 3:39
Jon_Boy10-Feb-09 3:39 
AnswerRe: Two questions regarding custom user controls and the toolbox. Pin
Dave Kreskowiak10-Feb-09 4:05
mveDave Kreskowiak10-Feb-09 4:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.