Click here to Skip to main content
15,886,689 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi guys,

I ve one project to finish end of this montth.

Thats about "news application" in Windows 8 Metro.


Im using standart Grid App for porject.

In SampleDataSource.cs file , I've written the code written below. However , I can't access the GridView Control by using the code given below.


myGrid.Items.Add(Convert.ToString(reader.ReadElementContentAsString())); // myGrid = GridView.

How can i overwhelm ths problem ? As many of you know , Windows Form Application has the propery of Access Modifiers to reach any control by setting public.


Thanks for your answer for the question I asked.

Sincerely,

H.BERAT YILDIRIM
Posted
Comments
BillWoodruff 21-Nov-13 11:02am    
"myGrid.Items.Add(Convert.ToString(reader.ReadElementContentAsString())); // myGrid = GridView."

This really doesn't make any sense: does 'myGrid hold a valid reference to the GridView Control ? Where is the GridView Control located ?

Please clarify your question, show more code, and show the specific code you used to assign the GridView to 'myGrid, and include any error messages.

1 solution

Just because you can do something, doesn't mean you should do something.

Setting controls as public is a very poor idea - it violates the principles of OOP and makes your code difficult to modify as any outside class could have used internal controls.

Instead, use properties and events to get / set data and signal that it is available.
I can't tell from your question exactly which way you need to go, but it should be covered here:

Transferring information between two forms, Part 1: Parent to Child[^]
Transferring information between two forms, Part 2: Child to Parent[^]
Transferring information between two forms, Part 3: Child to Child[^]

They are aimed at forms, but the same principle applies to UserControls as well: a form (or another UserControl) containing a UserControl is the parent, the UserControl is the child.
 
Share this answer
 

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