私はGUIプログラミングに全く新しいので、ピクチャボックスのリストについては少し助けが必要です。.NETのコレクションとオブジェクトのメソッドへのアクセス
アイデアは、私にはピクチャボックスのリストがあるということです。ユーザーが1つをクリックすると、(たとえば)Fixed3Dに選択されたBorderStyleプロパティを変更し、残りのコレクションの境界をFixedSingle(またはそのようなもの)に変更したいと思います。このようなことをする正しい方法は何ですか?もっと大きな写真があると思います。あるクラスのメソッドを取得して、それに関する情報を持たずに別のメソッドを呼び出す方法はありますか?
class myPicture
{
private int _pictureNumber;
private PictureBox _box;
public myPicture(int order)
{
_box = new List<PictureBox>();
_box.Click += new System.EventHandler(box_click);
_pictureNumber = order;
}
public void setBorderStyle(BorderStyle bs)
{
_box.BorderStyle = bs;
}
public void box_click(object sender, EventArgs e)
{
//here I'd like to call the set_borders from myPicturesContainer, but I don't know or have any knowledge of the instantiation
}
}
class myPicturesContainer
{
private List<myPicture> _myPictures;
//constructor and other code omitted, not really needed...
public void set_borders(int i)
{
foreach(myPicture mp in _MyPictures)
mp.setBorderStyle(BorderStyle.FixedSingle);
if(i>0 && _MyPictures.Count>=i)
_MyPictures[i].setBorderStyle(BorderStyle.Fixed3d);
}
}
:ここ
は、私が何を意味するかの非常に簡単な例です。たとえば、WPFでは、プロパティのバインドやスタイル(および場合によってはテンプレート)を使用します。 –