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. C#
  4. SelectedItem not working??? I'm stumped!

SelectedItem not working??? I'm stumped!

Scheduled Pinned Locked Moved C#
csharpdatabasegraphicsxmljson
4 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.
  • S Offline
    S Offline
    SpeBeeTo
    wrote on last edited by
    #1

    Hello, I have a C# program I'm working on, and I finally got over a large hurdle, only to encounter the next. :laugh: I finally am able to display an image in my form (Working on a PocketPC), as well as other info that is located in an XML file. The problem is, is that I think the SelectedItem Property isn't syncing with the rest of the items.... Could someone tell me where i'm going wrong? I'd really appreciate input. :) Here it goes: xmlFileName = "\\Program Files\\SmartDeviceApplication1\\fragenkatalog.xml"; xsdFileName = "\\Program Files\\SmartDeviceApplication1\\fragenkatalog.xsd"; FileStream FsXML = new FileStream(xmlFileName,FileMode.Open); FileStream FsXSD = new FileStream(xsdFileName,FileMode.Open); XmlTextReader xtrXSD = new XmlTextReader(FsXSD); fragenkatalogDS.ReadXmlSchema(xtrXSD); xtrXSD.Close(); FsXSD.Close(); XmlTextReader xtrXML = new XmlTextReader(FsXML); fragenkatalogDS.ReadXml(xtrXML); xtrXML.Close(); FsXML.Close(); DataTable dt = fragenkatalogDS.Tables["fragenkatalog"]; ca_id.DataSource = dt; ca_id.DisplayMember = "ca_titel"; string root = "\\Program Files\\SmartDeviceApplication1\\"; DataRowView drv = (DataRowView)ca_id.SelectedItem; ca_bildurl.Image = new Bitmap(System.IO.Path.Combine(root,drv.Row["ca_bildurl1"].ToString())); ca_titel.DataBindings.Add("Text",dt,"ca_titel"); ca_alter.DataBindings.Add("Text",dt,"ca_alter"); ca_sex.DataBindings.Add("Text",dt,"ca_sex"); burl.DataBindings.Add("Text",dt,"ca_bildurl1"); } The problem I've been having (I think) is with this line: DataRowView drv = (DataRowView)ca_id.SelectedItem; It seems as though it's not displaying any other image other than the first one in the database. Any ideas? Thanks a million! Martina

    K S 2 Replies Last reply
    0
    • S SpeBeeTo

      Hello, I have a C# program I'm working on, and I finally got over a large hurdle, only to encounter the next. :laugh: I finally am able to display an image in my form (Working on a PocketPC), as well as other info that is located in an XML file. The problem is, is that I think the SelectedItem Property isn't syncing with the rest of the items.... Could someone tell me where i'm going wrong? I'd really appreciate input. :) Here it goes: xmlFileName = "\\Program Files\\SmartDeviceApplication1\\fragenkatalog.xml"; xsdFileName = "\\Program Files\\SmartDeviceApplication1\\fragenkatalog.xsd"; FileStream FsXML = new FileStream(xmlFileName,FileMode.Open); FileStream FsXSD = new FileStream(xsdFileName,FileMode.Open); XmlTextReader xtrXSD = new XmlTextReader(FsXSD); fragenkatalogDS.ReadXmlSchema(xtrXSD); xtrXSD.Close(); FsXSD.Close(); XmlTextReader xtrXML = new XmlTextReader(FsXML); fragenkatalogDS.ReadXml(xtrXML); xtrXML.Close(); FsXML.Close(); DataTable dt = fragenkatalogDS.Tables["fragenkatalog"]; ca_id.DataSource = dt; ca_id.DisplayMember = "ca_titel"; string root = "\\Program Files\\SmartDeviceApplication1\\"; DataRowView drv = (DataRowView)ca_id.SelectedItem; ca_bildurl.Image = new Bitmap(System.IO.Path.Combine(root,drv.Row["ca_bildurl1"].ToString())); ca_titel.DataBindings.Add("Text",dt,"ca_titel"); ca_alter.DataBindings.Add("Text",dt,"ca_alter"); ca_sex.DataBindings.Add("Text",dt,"ca_sex"); burl.DataBindings.Add("Text",dt,"ca_bildurl1"); } The problem I've been having (I think) is with this line: DataRowView drv = (DataRowView)ca_id.SelectedItem; It seems as though it's not displaying any other image other than the first one in the database. Any ideas? Thanks a million! Martina

      K Offline
      K Offline
      kselman
      wrote on last edited by
      #2

      need more code... if your seeing the same result without a crash your probably acessing the parent object in your heirarchy. what control is ca_id ?

      S 1 Reply Last reply
      0
      • K kselman

        need more code... if your seeing the same result without a crash your probably acessing the parent object in your heirarchy. what control is ca_id ?

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

        Here's my XML code: 4 head ap kopf_ap.jpg 0 999 n And the cs code public ADONETDataBinding() { InitializeComponent(); fragenkatalogDS = new DataSet(); fragenkatalogDS.Locale = CultureInfo.CurrentCulture;string xmlFileName; xmlFileName = "\\Program Files\\SmartDeviceApplication1\\fragenkatalog.xml"; xsdFileName = "\\Program Files\\SmartDeviceApplication1\\fragenkatalog.xsd"; FileStream FsXML = new FileStream(xmlFileName,FileMode.Open); FileStream FsXSD = new FileStream(xsdFileName,FileMode.Open); XmlTextReader xtrXSD = new XmlTextReader(FsXSD); fragenkatalogDS.ReadXmlSchema(xtrXSD); xtrXSD.Close(); FsXSD.Close(); XmlTextReader xtrXML = new XmlTextReader(FsXML); fragenkatalogDS.ReadXml(xtrXML); xtrXML.Close(); FsXML.Close(); DataTable dt = fragenkatalogDS.Tables["fragenkatalog"]; ca_id.DataSource = dt; ca_id.DisplayMember = "ca_titel"; string root = "\\Program Files\\SmartDeviceApplication1\\"; DataRowView drv = (DataRowView)ca_id.SelectedItem; ca_bildurl.Image = new Bitmap(System.IO.Path.Combine(root,drv.Row["ca_bildurl1"].ToString())); ca_titel.DataBindings.Add("Text",dt,"ca_titel"); ca_alter.DataBindings.Add("Text",dt,"ca_alter"); ca_sex.DataBindings.Add("Text",dt,"ca_sex"); burl.DataBindings.Add("Text",dt,"ca_bildurl1"); } /// /// /// Clean up any resources being used. /// protected override void Dispose( bool disposing ) { base.Dispose( disposing ); } Thanks again!

        1 Reply Last reply
        0
        • S SpeBeeTo

          Hello, I have a C# program I'm working on, and I finally got over a large hurdle, only to encounter the next. :laugh: I finally am able to display an image in my form (Working on a PocketPC), as well as other info that is located in an XML file. The problem is, is that I think the SelectedItem Property isn't syncing with the rest of the items.... Could someone tell me where i'm going wrong? I'd really appreciate input. :) Here it goes: xmlFileName = "\\Program Files\\SmartDeviceApplication1\\fragenkatalog.xml"; xsdFileName = "\\Program Files\\SmartDeviceApplication1\\fragenkatalog.xsd"; FileStream FsXML = new FileStream(xmlFileName,FileMode.Open); FileStream FsXSD = new FileStream(xsdFileName,FileMode.Open); XmlTextReader xtrXSD = new XmlTextReader(FsXSD); fragenkatalogDS.ReadXmlSchema(xtrXSD); xtrXSD.Close(); FsXSD.Close(); XmlTextReader xtrXML = new XmlTextReader(FsXML); fragenkatalogDS.ReadXml(xtrXML); xtrXML.Close(); FsXML.Close(); DataTable dt = fragenkatalogDS.Tables["fragenkatalog"]; ca_id.DataSource = dt; ca_id.DisplayMember = "ca_titel"; string root = "\\Program Files\\SmartDeviceApplication1\\"; DataRowView drv = (DataRowView)ca_id.SelectedItem; ca_bildurl.Image = new Bitmap(System.IO.Path.Combine(root,drv.Row["ca_bildurl1"].ToString())); ca_titel.DataBindings.Add("Text",dt,"ca_titel"); ca_alter.DataBindings.Add("Text",dt,"ca_alter"); ca_sex.DataBindings.Add("Text",dt,"ca_sex"); burl.DataBindings.Add("Text",dt,"ca_bildurl1"); } The problem I've been having (I think) is with this line: DataRowView drv = (DataRowView)ca_id.SelectedItem; It seems as though it's not displaying any other image other than the first one in the database. Any ideas? Thanks a million! Martina

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

          As a side note, (for what it's worth) If I remove the 1st image listed (kopf.jpg) from the directory (i.e. I delete the jpg file), the whole program doesn't work. :S

          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