It's me again, with a weird problem. I created a code which reads xml file and uses g.Drawstring function to get my sorted xml text to pictureBox1. So I got advanced and made the pictureBox scrollable and noticed the problem. When the text in pictureBox was off screen (invisible), when I scrolled back to it, it wasn't there anymore. Same happens if I just take my application and drag it off screen, so that text disappears, the text gets deleted, but if I load my program again (browse the xml file again) it refreshes, but that doesn't help, becuase I need to make it so that the text is always there. Here is a part of my code, I hope it helps:
private void DrawInPictureBox(int index)
{
pictureBox1.Refresh();
using (XmlReader reader = XmlReader.Create(openFileDialog1.FileNames.ElementAt(index)))
{
y = 0;
while (reader.Read())
{
if (reader.IsStartElement())
{
if (reader.Name == "Something")
{
string Dat = reader.GetAttribute("Dat");
Graphics g = pictureBox1.CreateGraphics();
if (reader.Read())
{
string m = reader.Value.Trim();
g.DrawString(m, new Font("Arial", 10), Brushes.Black, 0, y * 15 + 20);
g.DrawString(Dat + "ok", new Font("Arial", 10), Brushes.Black, 150, y * 15 + 20);
y = y + 1;
}}}}}}
The pictureBox has a panel underneath it, so it is scrollable, but even if there is no panel the text gets deleted when taken off screen.
Thank you!