Autor Beitrag
Maldö
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 24



BeitragVerfasst: So 09.01.11 07:20 
Hi,

Ich baue in meinen Downloader auf der Startseite einen Newsfeed ein. Der klappt auch super! Die News kommen wie ich will per XML an und werden ausgegeben.

In der XML gibt für jeden Newsbeitrag das Attribute: picture

das beinhaltet entweder das "Nopic.jpg" oder das für den newsbeitrag.

Jenachdem ob eins angegeben wurde.

Da es meine Webseite ist weiß ich ja wo da Bild liegt und brauche nur den Dateinamen :-)

Aber wie liste ich den Bilder neben meinen Newsbeiträgen auf?.

Ich hab da an eine PictureBox gedacht under BackgroundLayout.Zoom das BIld immer auf Top Größe halten.

leider zeigt er immer nur das bild von EINER PictureBox an.

Hier der Code:


ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
//Boxes erstellen

PictureBox[] Pi = new PictureBox[images];
            for (int u = 0; u < images-1; i++)
            {

                if (File.Exists(Application.StartupPath + @"\feed\" + i + "_news.jpg"))
                {
                    Pi[u] = new PictureBox();
                    Pi[u].BackgroundImage = Image.FromFile(Application.StartupPath + @"\feed\" + i + "_news.jpg");
                    Pi[u].BackgroundImageLayout = ImageLayout.Zoom;
                    Pi[u].Size = new Size(100300);
                    Pi[u].Location = new Point(groupBox1.Width - 400, locz3);
                    locz3 = locz3 + 100;
                 
                }
            }


// Controlls hinzufügen
   foreach (PictureBox Pbox in Pi) {
                panel2.ExecuteThreadSafe(() => panel2.Controls.Add(Pbox));
            
            }


Gibt es dafür vieleicht einfachere Methode oder bessere?

vg

Maldö
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19315
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 09.01.11 09:31 
user profile iconMaldö hat folgendes geschrieben Zum zitierten Posting springen:
ausblenden C#-Quelltext
1:
2:
3:
4:
            for (int u = 0; u < images-1i++)
            {

                if (File.Exists(Application.StartupPath + @"\feed\" + i + "_news.jpg"))
Also irgendwie bist du mit deinen Schleifenvariablen durcheinander gekommen... und da u nie verändert wird, sollte das eine nette Endlosschleife sein, wenn denn i überhaupt existiert...
Maldö Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 24



BeitragVerfasst: So 09.01.11 09:55 
user profile iconjaenicke hat folgendes geschrieben Zum zitierten Posting springen:
user profile iconMaldö hat folgendes geschrieben Zum zitierten Posting springen:
ausblenden C#-Quelltext
1:
2:
3:
4:
            for (int u = 0; u < images-1i++)
            {

                if (File.Exists(Application.StartupPath + @"\feed\" + i + "_news.jpg"))
Also irgendwie bist du mit deinen Schleifenvariablen durcheinander gekommen... und da u nie verändert wird, sollte das eine nette Endlosschleife sein, wenn denn i überhaupt existiert...




danke....
leider zeigt er weiterhin nur 1 bild an :(
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19315
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 09.01.11 09:58 
Was heißt das denn? Ein Bild mehrfach? Nur ein Bild insgesamt?
Maldö Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 24



BeitragVerfasst: So 09.01.11 10:00 
user profile iconjaenicke hat folgendes geschrieben Zum zitierten Posting springen:
Was heißt das denn? Ein Bild mehrfach? Nur ein Bild insgesamt?

ein bild gesamt...

restlichen picture boxes bleiben leer..(erkenne ich am rahmen, den sie erzeugen)
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19315
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 09.01.11 10:05 
Und was sagt der Debugger? Wenn du da Schritt für Schritt durchgehst, stimmen die Dateinamen usw.?

Und wie sieht der Code denn jetzt aus?
Maldö Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 24



BeitragVerfasst: So 09.01.11 10:36 
also die Dateinamen stimmen alle...

Code:
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
 string[] files = Directory.GetFiles("feed""*.jpg");
            int images = files.Length;

            int locz3 = 60;
            PictureBox[] Pi = new PictureBox[images];
            for (int u = 0; u < images-1; u++)
            {

                if (File.Exists(Application.StartupPath + @"\feed\" + u + "_news.jpg"))
                {
                    Pi[u] = new PictureBox();
                    Pi[u].BackgroundImage = Image.FromFile(Application.StartupPath + @"\feed\" + u + "_news.jpg");
                    Pi[u].BackgroundImageLayout = ImageLayout.Zoom;
                    Pi[u].BorderStyle = BorderStyle.FixedSingle;
                    Pi[u].Size = new Size(100300);
                    Pi[u].Location = new Point(groupBox1.Width - 400, locz3);
                    locz3 = locz3 + 100;
                 
                }
            }

           foreach (PictureBox Pbox in Pi) {
                panel2.ExecuteThreadSafe(() => panel2.Controls.Add(Pbox));
            
            }
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19315
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 09.01.11 12:36 
Gut, schaue ich mal nochmal drauf...
Also du setzt die Größe des Bildes auf 300, und versetzt das nächste dann nur um 100? Naja, meinst du nicht, dass sich das dann überlappt?
user profile iconMaldö hat folgendes geschrieben Zum zitierten Posting springen:
Pi[u].Size = new Size(100, 300);
Pi[u].Location = new Point(groupBox1.Width - 400, locz3);
locz3 = locz3 + 100;
Maldö Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 24



BeitragVerfasst: So 09.01.11 21:36 
aye....stimmt....danke jetzt funzt es:-)

perfekt:D