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
  1. Home
  2. General Programming
  3. C#
  4. picturebox binding

picturebox binding

Scheduled Pinned Locked Moved C#
questiondatabasewpfwcf
2 Posts 2 Posters 0 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.
  • B Offline
    B Offline
    balkang
    wrote on last edited by
    #1

    Hello, I want to keep the personal details including a picture of a user and store this information in a database and display later. I binded the textboxes to a datatable but could not bind the picturebox and the image. I tried the code below.. How can I handle that?? string selectStudent = "SELECT * FROM Students "; daStudent = new SqlDataAdapter(selectStudent, conn); dsStudent = new DataSet(); cbStudent = new SqlCommandBuilder(daStudent); daStudent.Fill(dsStudent, "Students"); pictureBox.DataBindings.Add("Byte[]", dsStudent, "Students.Photo");

    T 1 Reply Last reply
    0
    • B balkang

      Hello, I want to keep the personal details including a picture of a user and store this information in a database and display later. I binded the textboxes to a datatable but could not bind the picturebox and the image. I tried the code below.. How can I handle that?? string selectStudent = "SELECT * FROM Students "; daStudent = new SqlDataAdapter(selectStudent, conn); dsStudent = new DataSet(); cbStudent = new SqlCommandBuilder(daStudent); daStudent.Fill(dsStudent, "Students"); pictureBox.DataBindings.Add("Byte[]", dsStudent, "Students.Photo");

      T Offline
      T Offline
      tarasn
      wrote on last edited by
      #2

      You can bind picturebox using Format event ... // your code goes here ... Binding binding = new Binding("Image", dsStudent, "Students.Photo"); binding.Format+=new ConvertEventHandler(binding_Format); pictureBox.DataBindings.Add(binding); And in Format event you must convert byte [] array to Image private void binding_Format(object sender, ConvertEventArgs e) { using(MemoryStream stream = new MemoryStream((byte [])e.Value)) { e.Value = Image.FromStream(stream); } } DevIntelligence.com - My blog for .Net Developers

      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