Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I have a list of items in the main window and i have a user control.Thers is some Values or fields related to each of the items in the list.i need to show the fields related to each item in the list on a data grid as i select each item.I need to have only the contents of items that i selected on the list.When selecting next item fields related to this must be gone from grid.and so on.How can it be done?Anyone have any idea.

please help me
Posted
Updated 23-Jul-13 19:30pm
v2
Comments
Varsha Ramnani 24-Jul-13 1:32am    
Where do you want to add the new User Controls on a new window or the same window where button is clicked?
I think what you need is binding your listview item to your UserControl and the values will be displayed according to the selected items because of binding.
prapaug 24-Jul-13 1:46am    
i want to add the user controls in same window where the button is present.I'm a beginner in c#.so can you write a code for me?
Varsha Ramnani 24-Jul-13 1:50am    
The code provided by sarin is correct you just need to add Stackpanel in you designer along with the button.
Sarin VT 24-Jul-13 1:58am    
So you got the solution??
Then please upvote my solution. Also please Accept the Solution.
Thank you.

1 solution

Please find the code.

UserControl userControl = new UCTeamTweet();
userControl.Width = Convert.ToInt32("500");
userControl.Height = Convert.ToInt32("900");
userControl.HorizontalAlignment = HorizontalAlignment.Left;
userControl.VerticalAlignment = VerticalAlignment.Top;
stkPnlSearch.Children.Add(userControl); // Add to the stack panel.


Perform this action inside button_click event.
 
Share this answer
 
Comments
prapaug 24-Jul-13 1:47am    
so first i want to create stack panel.right?
Sarin VT 24-Jul-13 1:49am    
Yes.
If you found the solution please mark this solution as answered.
Please feel free to ask any question.
prapaug 24-Jul-13 1:57am    
Sarin,i have a list of items.Not a single button.when i select each item the data related to that should be listed in the grid.and when i select next item,then data corresponding to that.And the previous data should not be in the grid.If possible Please help me with a complete code.
Sarin VT 24-Jul-13 2:03am    
Can you please paste your code here. (The main window)
Need more information about the items and values.
prapaug 24-Jul-13 2:16am    
There is nothing in the main window.i wanna create all these....
A list of things
A grid.
Some data associated with each thing in list(it can be anything...a sigle thing is neede to differentiate)
on clicking each item in ist i should be able to view content associated with each...
If you got my idea ,please let me know

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900