• ¡Welcome to Square Theme!
  • This news are in header template.
  • Please ignore this message.
مهمان عزیز خوش‌آمدید. ورود عضــویت


امتیاز موضوع:
  • 6 رای - 3 میانگین
  • 1
  • 2
  • 3
  • 4
  • 5
Title: ایجاد شی در ران تایم
حالت موضوعی
#1
ُسلام دوستان

می خوام 161 PictureBox در حالت RunTime روی فرم اضافه کنم و یک رویداد برای کل این PictureBoxها در نظر بگیریم. هنگامی که کلیک چپ ماوس رو پایین نگه داشته و روی PictureBoxها حرکت دادیم. رنگ PictureBoxها عوض بشه


ممنون:heart:
 
پاسخ
#2
منظورت دقیقا از حالت run time چیه؟
گروه دور همی پارسی کدرز
https://t.me/joinchat/GxVRww3ykLynHFsdCvb7eg
 
پاسخ
#3
من نمیدونم اگه شمارا نداشتم چه میکردم با این همه سوال بی جواب!
میخوام زمانی که برنامه اجرا شد این اتفاق بیوفته در حالت طراحی نمیخوام!
 
پاسخ
#4
فکر کنم تا الان بیشتر سوالهاتو جواب دادم اونهای هم که جواب ندادم وقت نکردم به زودی جوای میدم :P
به این روش میگن Create Control at Runtime
خوب event هم تو سورس زیر یه مثال برات گذاشته شده تا راحت بفهمی :-)


We are going to create a link control and an image control one next to each other. First we have to set which control we are going to create, so in the form class area place:
کد:
private PictureBox PicBox;
private LinkLabel Blue;
Now when you want to create the link and picturebox call this
کد:
//CREATES AN EVENT HANDLER FOR THE LINK
EventHandler handler = new EventHandler(LinkLabel_Click);

//BUILD CONTROL LINK
Blue = new LinkLabel();
Blue.Text = "Link Control";
Blue.Location = new Point(30, 20);
Blue.Size = new Size(150, 20);
Blue.LinkBehavior = System.Windows.Forms.LinkBehavior.HoverUnderline;
Blue.Click +=handler;
//CREATES AN NEW PICTUREBOX AND FILLS IT WITH A ICON
PicBox = new PictureBox();
PicBox.Image = Image.FromFile(@"c:\pic.ico");
PicBox.Top = 20;
PicBox.Width = 16;
PicBox.Height = 16;
PicBox.Left = 10;
//ADD CONTROLS
Controls.Add(PicBox);
Controls.Add(Blue);
You created a handler for the click event of the link button so you could now could this in:
کد:
private void LinkLabel_Click(object sender, EventArgs e)
{
    //SPLITS THE DATA SO U CAN GET THE TEXT , U COULD PARSE IT THROUGH A CASE STATMENT FOR DIFFERENT SELECTIONS
    string Data = Convert.ToString(sender);
    string [] Split = Data.Split(new Char [] {':'});
    MessageBox.Show("Link Clicked :" + Convert.ToString(Split[1]));
}
If you wanted to create a list of controls you could use the panel control and set the autoscroll property to true so everytime another control is added with a larger top value the scrollbar would appear giving the user the impression of a list control. You can add controls to a panel control simply by putting
کد:
panel1.Controls.Add(PicBox);
panel1.Controls.Add(Blue);
گروه دور همی پارسی کدرز
https://t.me/joinchat/GxVRww3ykLynHFsdCvb7eg
 
پاسخ
  


موضوعات مشابه ...
موضوع نویسنده پاسخ بازدید آخرین ارسال
Rainbow ایجاد ارتباط master- detail بین دو تیبل analyze 0 2,195 12-08-2011، 03:25 PM
آخرین ارسال: analyze
  ایجاد نوشته های گرافیکی Ghoghnus 0 1,807 10-31-2011، 02:26 PM
آخرین ارسال: Ghoghnus

پرش به انجمن:


Browsing: 1 مهمان