Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. XML / XSL
  4. Insert string to Bitmap path?

Insert string to Bitmap path?

Scheduled Pinned Locked Moved XML / XSL
graphicsquestioncsharpxmlhelp
3 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SpeBeeTo
    wrote on last edited by
    #1

    How can I do this? I simply want to add the "im" field (which is in the XML file) at the end of the path of the new Bitmap line of code, so that the correct jpg is shown. I've created filestreams and everything works fine for the the text fields. The images are located in the "Program Files\SmartDeviceApplication1" directory, as is the XML file. If I type in the actual name of an image, it works, but of course the image is shown for every entry. (So I know the directory path is correct) Right now I'm getting "cannot convert string to System.Drawing.Image" In the simplest sense, I want to do this: \\Program Files\\SmartDeviceApplication1\\<im> so that it reads: \\Program Files\\SmartDeviceApplication1\\kopf_ap.jpg Any help is appreciated! Martina Snippet XML file: <im>>kopf_ap.jpg</im> Snippet Code (C#) picbox.DataBindings.Add("Image",dt,"im"); Bitmap bmp= new Bitmap("\\Program Files\\SmartDeviceApplication1\\"); this.picbox.Image = bmp +"im";

    C 1 Reply Last reply
    0
    • S SpeBeeTo

      How can I do this? I simply want to add the "im" field (which is in the XML file) at the end of the path of the new Bitmap line of code, so that the correct jpg is shown. I've created filestreams and everything works fine for the the text fields. The images are located in the "Program Files\SmartDeviceApplication1" directory, as is the XML file. If I type in the actual name of an image, it works, but of course the image is shown for every entry. (So I know the directory path is correct) Right now I'm getting "cannot convert string to System.Drawing.Image" In the simplest sense, I want to do this: \\Program Files\\SmartDeviceApplication1\\<im> so that it reads: \\Program Files\\SmartDeviceApplication1\\kopf_ap.jpg Any help is appreciated! Martina Snippet XML file: <im>>kopf_ap.jpg</im> Snippet Code (C#) picbox.DataBindings.Add("Image",dt,"im"); Bitmap bmp= new Bitmap("\\Program Files\\SmartDeviceApplication1\\"); this.picbox.Image = bmp +"im";

      C Offline
      C Offline
      Curtis Schlak
      wrote on last edited by
      #2

      Maybe you need to do this?

      picbox.DataBindings.Add("Image",dt,"im");
      Bitmap bmp= new Bitmap("\\Program Files\\SmartDeviceApplication1\\" + im);
      this.picbox.Image = bmp;

      S 1 Reply Last reply
      0
      • C Curtis Schlak

        Maybe you need to do this?

        picbox.DataBindings.Add("Image",dt,"im");
        Bitmap bmp= new Bitmap("\\Program Files\\SmartDeviceApplication1\\" + im);
        this.picbox.Image = bmp;

        S Offline
        S Offline
        SpeBeeTo
        wrote on last edited by
        #3

        Thank you, I had tried that, but it didn't seem to work. I ended up doing this: string root = "\\Program Files\\SmartDeviceApplication1\\"; DataRowView drv = (DataRowView)ca_id.SelectedItem; ca_bildurl.Image = new Bitmap(System.IO.Path.Combine(root,drv.Row["im"].ToString())); I now have another problem - the SelectedItem doesn't seem to work, but at least the first image is being shown. :laugh: Thanks for your reply, though!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups