c# - PictureBox clearing when dragged out of screen boundries in Visual Studio 2013 -


it's me again, weird problem. created code reads xml file , uses g.drawstring function sorted xml text picturebox1. got advanced , made picturebox scrollable , noticed problem. when text in picturebox off screen (invisible), when scrolled it, wasn't there anymore. same happens if take application , drag off screen, text disappears, text gets deleted, if load program again (browse xml file again) refreshes, doesn't help, becuase need make text there. here part of code, hope 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 panel underneath it, scrollable, if there no panel text gets deleted when taken off screen.

thank you!

some points:

  • it best if can subscribe picturebox.onpaint event , use e.graphics draw xml elements
  • with regards scroll, there possibility location of scrollable control moving in 1 direction makes invisible screen.

try debug location of scroll position writing values of scroll-x , scroll-y position in output window via console.writeline() or system.debug.writeline(), chances there negative values, or out of boundary values. (in case value of y in g.drawstring())


Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -