获取具有picturebox的面板的索引。 [英] Get the index of the panel that has picturebox.

查看:60
本文介绍了获取具有picturebox的面板的索引。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在课堂上,我有一组面板,每个面板都包含相同的图片框。



In a class, I have an array of panels which each contains the same picturebox.

public Panel[] NumberPanel;
public PictureBox AddBox;
NumberPanel.Controls.Add(ABCBox);

AddBox.Click += new System.EventHandler(AddBox_Click);





创建对象时创建面板和图片。



如果点击其中一个面板中的一张图片,我怎么知道面板的索引。



private void AddBox_Click(object sender,EventArgs e)

{

int index;

index = ???;

}



When creating an object it creates the panel and the picture in it.

How can I know the index of the panel when clicked on one of the pictures in one of the panels.

private void AddBox_Click(object sender, EventArgs e)
{
int index;
index=???;
}

推荐答案

我不认为有任何直接方法,因为它定义了你需要的类结构保持面板的索引作为内部人控件的成员。



我相信你已经使用自定义控件来创建保存面板和图片框的对象。



您可以做的一件事是通过将索引保持为自定义控件或类的属性来公开模拟面板内部的picbox(customcontrol)的自定义事件。持有面板/图片电子邮箱。
I dont think that there is any direct method since its you defines the class structure you need to keep the index of the panel as a member to the insider control.

I believe you have used a custom control to create your object which holds panel and picturebox.

One thing you can do is expose custom event which simulates that picbox inside the panel(customcontrol) is clicked by keeping the index as a property to the custom control or class which holds the panel/picture box.


这篇关于获取具有picturebox的面板的索引。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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