Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
| Search | Today's Posts | Mark Forums Read
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old August 5th, 2005, 08:45 AM
Authorized User
 
Join Date: Apr 2005
Location: Kuruman, Northern Cape, South Africa.
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to EricJ
Default 1 form, contains two seperate controls

Hey all, I need some guidance. I'm trying to simulate an environment where you have two user created controls place on a form. A treeview control on the left, like in windows explorer [old trick] and a custom control to handle the edit of item values as selected from the treeview control on the left.

To put it in simple terms I have a treeview on the left and a custom control on the right. The user clicks on a node item and the custom control on the left gets populated with the relevant information surrounding the selection. Now lets say for example the treeview gets populated with usernames and the user selects, Michael Jackson, should the custom control be populated with Michael Jackson's name [Michael, textbox1], [Jackson, textbox2], [TelephoneNumber, textbox3], etc. I have a single form that acts as a container for these two controls but all events, as per control are controlled by that control.

I can, retrieve the information as per selection from the treeview using the AfterSelect-Event's [e] argument: e.Node.Tag and successfully pass the value to the custom user control, but I cannot add the required values into the textboxes. I would like to know why I cannot do this and if it possible how to get around this scenario.

  #2 (permalink)  
Old August 8th, 2005, 08:24 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I think the problem is that you don't have any public properties exposed on your user control. If the user control has two textboxes (username, password) and you want to be able to set the values of those textboxes from outside the control, then you need to provide public properties that expose the .Text property of each textbox. That way the event raised by the tree is handled by the container (form) and it in turn populates the textboxes thru the user control's public properties.

-Peter
  #3 (permalink)  
Old August 10th, 2005, 04:48 AM
Authorized User
 
Join Date: Apr 2005
Location: Kuruman, Northern Cape, South Africa.
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to EricJ
Default

Hey Peter!!

Yes that is true, but reading through my own post just now I see that I forgot to mention that I have public properties set to receive the required value from the control [the treeview control]. Let me try and step you through my code because I just cannot seem to figure out why this is happening.

1.) The user fires up the application and is greeted with a blank windows form
2.) The user makes a selection from a menu - Edit - Users
3.) The Menu_Click Event fires up 3 events
3.1) The Windows Form gets populated with two custom user controls a.) a treeview on the left and b.) a edit control on the right
3.2) The treeview gets populated with information from my sql database regarding the menu selection, this case UserInformation
3.3) The treeview waits for the user to make his/her selection
4.) Once a selection is made, I capture the Tag from the node the user clicked on as I'll be using it to gather all relevant information to be displayed in the edit control on the right. This is done by declaring a Public Property in the EditControl called NodeTag.
5.) Once the NodeTag property holds the value from the TreeViewControl should I populate the EditControl's two textboxes with the required values, ok here's the problem.

I have a public method called PopulateControl which makes use of a DataTable set in as a reference to my dataset which I used to populate the treeview at step 4. For this reason I'm using the following code:

Public Sub PopulateControl() '// Notice no constructor as I'll be using NodeTag

    Dim m_Table As Datatable = m_Dataset.Tables("Users") '// m_Dataset is Global
    Dim m_Rows As DataRow = m_Table.Select("USERID = '" & m_NodeTag & "'") '// Return the values as a datarow
    '// I've stepped through the code and both m_Table and m_Rows gets populated
    '// with the values I'm looking for (everything that is specific to USERID
    '// So the problem isn't in my DataTable, right?

    Me.txtFirstname.Text = m_Rows(0).Item(2).ToString
    Me.txtLastname.Text = m_Rows(0).Item(3).ToString

End Sub

This in theory should display both the Firstname and the Lastname as per selection but it doesn't. I thought that the problem might be the controls and cross reference of data, so I made the treeview part of the Windows Form and not as a custom usercontrol as i've been using thus far and it works perfectly. As soon as I instantiate the custom usercontrol treeview doesn't it display anything in two textboxes?



Similar Threads
Thread Thread Starter Forum Replies Last Post
CreatBackup:=True but in seperate folder mona_upm84 Excel VBA 0 July 18th, 2008 12:07 AM
Call to subroutine from seperate workbook Coby Excel VBA 2 February 1st, 2008 10:15 PM
seperate string by ^ bbvic XSLT 7 July 25th, 2007 02:00 AM
Why not seperate OBJ layer susahin80 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 January 19th, 2007 03:51 PM
Seperate Code JsonTerre1 BOOK: ASP.NET Website Programming Problem-Design-Solution 1 November 7th, 2004 04:38 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.