VS 2012中的访问修饰符& Windows 8 App? [英] Access modifiers in VS 2012 & Windows 8 App?

查看:69
本文介绍了VS 2012中的访问修饰符& Windows 8 App?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨伙计们,



我有一个完成这个月底的项目。



多数民众赞成关于Windows 8 Metro中的新闻应用程序。





我使用标准网格应用程序进行项目。



在SampleDataSource.cs文件中,我编写了下面编写的代码。但是,我无法使用下面给出的代码访问GridView控件。





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



我怎么能压倒这个问题?正如你们许多人所知,Windows Form Application具有Access Modifiers的功能,可以通过设置公共来实现任何控制。





感谢您的支持回答我问的问题。



此致,



H.BERAT YILDIRIM

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

推荐答案

仅仅因为你 可以 做某事,并不代表你 做点什么。



将控件设置为 public 是一个非常糟糕的主意 - 它违反了原则OOP并且使您的代码难以修改,因为任何外部类都可以使用内部控件。



相反,使用属性和事件来获取/设置数据并发出信号表明它是可用。

我无法从你的问题中确切地知道你需要走哪条路,但是应该在这里介绍:



< a href =http://www.codeproject.com/Tips/548052/Transferring-information-between-two-forms-Part-1>转换器两种表格之间的信息,第1部分:父母与子女 [ ^ ]

在两个表格之间传递信息,第2部分:孩子到父母 [ ^ ]

在两种形式之间传递信息,第3部分:儿童到儿童 [ ^ ]



它们针对表单,但同样的原则也适用于UserControls:包含Us的表单(或另一个UserControl) erControl是父级,UserControl是子级。
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.


这篇关于VS 2012中的访问修饰符&amp; Windows 8 App?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆