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. Custom DataGridViewCell data binding question.

Custom DataGridViewCell data binding question.

Scheduled Pinned Locked Moved C#
questiondatabasewpfwcflearning
2 Posts 1 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
    Bliedtke
    wrote on last edited by
    #1

    I have created a custom datagridviewcell that is to take a double value from the database and parse it into a string that displays a date in a certain format. I have the conversion process working. The trouble that I am having is getting and pushing the double value to/from the database. Of course the FormattedValue that is generally pushed to the database is the string but I want the double that generated the string. Any ideas on how I can change the property that is bound to the database instead of FormattedValue? Brian

    B 1 Reply Last reply
    0
    • B Bliedtke

      I have created a custom datagridviewcell that is to take a double value from the database and parse it into a string that displays a date in a certain format. I have the conversion process working. The trouble that I am having is getting and pushing the double value to/from the database. Of course the FormattedValue that is generally pushed to the database is the string but I want the double that generated the string. Any ideas on how I can change the property that is bound to the database instead of FormattedValue? Brian

      B Offline
      B Offline
      Bliedtke
      wrote on last edited by
      #2

      I figured it out. What I did was override the cell's Paint method and paint the string I wanted displayed in the cell leaving the double value as the cells formattedValue. I then overrode the cell's ParseFormattedValue method to take the string that the user input, convert it to the appropriate double representation and make it the formattedValue of the cell. This displayed the correct value to the user while maintaining the correct double value as the cells value for pushing back to the database. I also had to create a new DataGrodViewEditControl to display the correct string to the user when editing. If anyone has a similar problem and wants a look at the code, email me at liedtke@frii.com. Brian

      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