vb@rchiv
VB Classic
VB.NET
ADO.NET
VBA
C#
sevAniGif - als kostenlose Vollversion auf unserer vb@rchiv CD Vol.5  
 vb@rchiv Quick-Search: Suche startenErweiterte Suche starten   Impressum  | Datenschutz  | vb@rchiv CD Vol.6  | Shop Copyright ©2000-2025
 
zurück

 Sie sind aktuell nicht angemeldet.Funktionen: Einloggen  |  Neu registrieren  |  Suchen

VB.NET - Fortgeschrittene
Re: Situationsabhängige Variablendeklaration 
Autor: Waver
Datum: 31.08.09 20:45

Hier noch den Code des Beispiels (in C#):
  private void Form1_Load(object sender, EventArgs e)
        {
            for (int i = 0; i < 12; i++)
            {
                PictureBox picture = new PictureBox();
 
                picture.AllowDrop = true;
                picture.MouseMove += OnPictureMouseMove;
                picture.DragDrop += OnPictureDragDrop;
                picture.DragEnter += OnPictureDragEnter;
                picture.BorderStyle = BorderStyle.FixedSingle;
                picture.Size = new Size(100, 100);
                picture.BackColor = Color.FromArgb(i * 20, 0, 0);
                this.flowLayoutPanel1.Controls.Add(picture);
            }
 
            this.flowLayoutPanel1.Height = _
              this.flowLayoutPanel1.Controls[this.flowLayoutPanel1.Controls.Cou_
              nt - 1].Bottom + 5;
        }
 
        private void OnPictureDragEnter(object sender, DragEventArgs e)
        {
            e.Effect = DragDropEffects.Move;
        }
 
        private void OnPictureDragDrop(object sender, DragEventArgs e)
        {
            PictureBox target = sender as PictureBox;
            if (target != null)
            {
                int targetIndex = FindPictureBoxIndex(target);
                if (targetIndex != -1)
                {
                    string pictureBoxFormat = typeof(PictureBox).FullName;
                    if (e.Data.GetDataPresent(pictureBoxFormat))
                    {
                        PictureBox source = e.Data.GetData(pictureBoxFormat) as _
                          PictureBox;
 
                        int sourceIndex = this.FindPictureBoxIndex(source);
 
                        if (targetIndex != -1)
                            this.flowLayoutPanel1.Controls.SetChildIndex( _
                              source, targetIndex);
                    }
                }
            }
        }
 
        private int FindPictureBoxIndex(PictureBox picture)
        {
            for (int i = 0; i < this.flowLayoutPanel1.Controls.Count; i++)
            {
                PictureBox target = this.flowLayoutPanel1.Controls as _
                  PictureBox;
 
                if (picture == target)
                    return i;
            }
            return -1;
        }
 
        private void OnPictureMouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                PictureBox picture = sender as PictureBox;
 
                picture.BorderStyle = BorderStyle.Fixed3D;
                picture.DoDragDrop(picture, DragDropEffects.Move);
 
            }
        }
alle Nachrichten anzeigenGesamtübersicht  |  Zum Thema  |  Suchen

 ThemaViews  AutorDatum
Situationsabhängige Variablendeklaration1.050Waver31.08.09 19:05
Re: Situationsabhängige Variablendeklaration732sollniss31.08.09 19:46
Re: Situationsabhängige Variablendeklaration710keco31.08.09 20:05
Re: Situationsabhängige Variablendeklaration849Waver31.08.09 20:27
Re: Situationsabhängige Variablendeklaration723sollniss31.08.09 20:32
Re: Situationsabhängige Variablendeklaration672Waver31.08.09 20:41
Re: Situationsabhängige Variablendeklaration735Waver31.08.09 20:45

Sie sind nicht angemeldet!
Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.

Einloggen  |  Neu registrieren

Funktionen:  Zum Thema  |  GesamtübersichtSuchen 

nach obenzurück
 
   

Copyright ©2000-2025 vb@rchiv Dieter Otter
Alle Rechte vorbehalten.
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein.

Diese Seiten wurden optimiert für eine Bildschirmauflösung von mind. 1280x1024 Pixel