🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.pl.comp.lang.csharp
Article #21220

Re: DoDragDrop w mojej wlasnej, osadzonej klasie

#21220
From: Polon
Date: Thu, 10 Dec 2009 01:08
81 lines
3673 bytes
> No to daj jakiś kawałek kodu.

Prosze bardzo:

public class Klocek //Klocek to pojedyncza "komorka" mojej planszy
        {
            private PictureBox obrazek;
            private char typObrazka; //to jest char poniewaz kod planszy 
skladac sie bedzie z ciagu literek, kazdy klocek jest
                                     //charakteryzowany przez jeden char
            private byte kolumna;
            private byte wiersz;

            private void DragDrop(object sender, DragEventArgs e)
            {
                this.obrazek.Image = (Bitmap)e.Data.GetData(typeof(Bitmap));

            }

            private void DragEnter(object sender, DragEventArgs e)
            {
                if (e.Data.GetDataPresent(typeof(Bitmap)))
                {
                    e.Effect = DragDropEffects.Copy;
                }
                else
                    {
                        e.Effect = DragDropEffects.None;
                    }
            }

            private void MouseDown(object sender, MouseEventArgs e)
            {
                PictureBox source = (PictureBox)sender;
                DoDragDrop(source.Image, DragDropEffects.Copy); <- tu sie 
wywala,

            }


            public Klocek(byte aWiersz, byte aKolumna, char aTypObrazka, 
ImageList aImageList, Panel aPanel)
            {
                typObrazka = aTypObrazka;
                //imageList = aImageList;
                kolumna = aKolumna;
                wiersz = aWiersz;

                obrazek = new PictureBox();
                obrazek.Image = aImageList.Images[aTypObrazka - 97]; //-97 
aby 'a' mialo indeks '0'
                obrazek.SizeMode = PictureBoxSizeMode.StretchImage;

                obrazek.Width = obrazekSzerokosc;
                obrazek.Height = obrazekWysokosc;

                obrazek.Left = aKolumna * obrazekSzerokosc;
                obrazek.Top = aWiersz * obrazekWysokosc;
                obrazek.AllowDrop = true;
                obrazek.DragEnter += new 
System.Windows.Forms.DragEventHandler(this.DragEnter);
                obrazek.DragDrop += new 
System.Windows.Forms.DragEventHandler(this.DragDrop);
                obrazek.MouseDown += new 
System.Windows.Forms.MouseEventHandler(this.MouseDown);

                klockiTabela[aWiersz, aKolumna] = this;

                aPanel.Controls.Add(obrazek);

            }
        }


komunikat o bledzie to:

Error 1 Cannot access a nonstatic member of outer type 
'System.Windows.Forms.Control' via nested type 'XXX.FrmEdytor.Klocek' 
D:\Lolek\JACEK\C#\moje programy\XXX\XXX\FrmEdytorGlowna.cs 72 17 XXX

Marek
Technical Details
Message-ID: <hfphls$jv1$1@news.onet.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!news.onet.pl!not-for-mail
References: <hfg8nk$q96$1@news.onet.pl> <hfgh0u$1lb$1@atlantis.news.neostrada.pl> <hfgpsq$f2o$1@news.onet.pl> <hfjhdt$ne9$1@nemesis.news.neostrada.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!news.onet.pl!not-for-mail
From: "Polon" <Polon@wp.pl>
Newsgroups: alt.pl.comp.lang.csharp
Subject: Re: DoDragDrop w mojej wlasnej, osadzonej klasie
Date: Thu, 10 Dec 2009 01:08:11 -0000
Organization: http://onet.pl
Lines: 82
Message-ID: <hfphls$jv1$1@news.onet.pl>
References: <hfg8nk$q96$1@news.onet.pl> <hfgh0u$1lb$1@atlantis.news.neostrada.pl> <hfgpsq$f2o$1@news.onet.pl> <hfjhdt$ne9$1@nemesis.news.neostrada.pl>
NNTP-Posting-Host: 92.3.34.66
Mime-Version: 1.0
X-Trace: news.onet.pl 1260407292 20449 92.3.34.66 (10 Dec 2009 01:08:12 GMT)
X-Complaints-To: niusy@onet.pl
NNTP-Posting-Date: Thu, 10 Dec 2009 01:08:12 +0000 (UTC)
In-Reply-To: <hfjhdt$ne9$1@nemesis.news.neostrada.pl>
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Windows Mail 6.0.6001.18000
X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6001.18049
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit