DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Need to set controls inside UserControl from another window

  1. #1
    Join Date
    Feb 2013

    Need to set controls inside UserControl from another window

    I have this user control that I have programmaticaly added to my main form. My control also inherits from a base user control. This base user control contains date and time textboxes with buttons to enable manually setting the date and time. One button formats the system time and date and displays them in the appropriate textboxes. The code for this is contained in the control.

    Now for my problem. I need to be able to launch another form which contains controls which allow me to increment or decrement the hour or minutes in my usercontrol. (It also contains a Callendar control) I am unable to access the textbox controls inside the usercontrol to set the value of each textbox. I've tried Public Property but it does not show up when I call either the baseUsercontrol or the target user controlfrom my form. It's the user control which launches the "Updating Form".

    I've looked on the NET for ideas but what I found was written in C#. My code is I know enough about c# to understand the jist of the code but not enough to be able to convert the code to vb.

    What I found and thought had possabilities was raising my own events. Great idea, but how can my main form know about the event until after the app is compiled and running? Remember, the control is added by code. I tried pasting the code I found into my control (modified to what I thought would make it work in my app) and wrote an event procedure in the MainForm as a test. It didn't work.

    It's late at night and I'm tired and frustrated so please, if I'm rambling and my explanation isn't clear, ask me some questions. I need help.


  2. #2
    Join Date
    Feb 2013
    Thanks to those who viewed my question.
    I solved the problem myself. I was looking to close to the active code.

    I launch the form Calender as a modal form. All I had to do was add the code to update the user control_1 after my call to ShowDialog.

    e.g. (DateTime1 is my user control_1)
    Dim retVal As MsgBoxResult
    With frmSetDateTime
    .DateInput = txtDate.Text
    .TimeInput = txtTime.Text
    txtDate.Text = frmSetDateTime.DateTime1.txtDate.Text
    txtTime.Text = frmSetDateTime.DateTime1.txtTime.Text
    End With

Similar Threads

  1. Replies: 0
    Last Post: 07-30-2008, 06:25 AM
  2. Replies: 0
    Last Post: 04-14-2001, 06:52 PM
  3. UserControl and knowing when all controls are loaded
    By Miha Markic in forum VB Classic
    Replies: 0
    Last Post: 04-02-2001, 09:02 AM
  4. usercontrol position in parent window
    By Alex Kennedy in forum VB Classic
    Replies: 2
    Last Post: 06-08-2000, 01:43 PM
  5. usercontrol position in parent window
    By Alex Kennedy in forum VB Classic
    Replies: 0
    Last Post: 06-08-2000, 01:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center