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. Formatting

Formatting

Scheduled Pinned Locked Moved C#
questionhelp
5 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
    bwood2020
    wrote on last edited by
    #1

    Hello, I am having problems formatting data in a datagridview and I am hoping someone out there can help me. How can I format data by column in a datagridview skipping the first row and beginning at the second row? Thank you for reading.

    S 1 Reply Last reply
    0
    • B bwood2020

      Hello, I am having problems formatting data in a datagridview and I am hoping someone out there can help me. How can I format data by column in a datagridview skipping the first row and beginning at the second row? Thank you for reading.

      S Offline
      S Offline
      snorkie
      wrote on last edited by
      #2

      Why don't you just create an empty first row? Normally you would do something like: DataGridViewRow dgvr = dgvPowerSavingsReport.Rows[dgvPowerSavingsReport.Rows.Add()]; instead do: //Empty Row dgvPowerSavingsReport.Rows.Add() //Actual data to work with DataGridViewRow dgvr = dgvPowerSavingsReport.Rows[dgvPowerSavingsReport.Rows.Add()]; Hogan

      B 1 Reply Last reply
      0
      • S snorkie

        Why don't you just create an empty first row? Normally you would do something like: DataGridViewRow dgvr = dgvPowerSavingsReport.Rows[dgvPowerSavingsReport.Rows.Add()]; instead do: //Empty Row dgvPowerSavingsReport.Rows.Add() //Actual data to work with DataGridViewRow dgvr = dgvPowerSavingsReport.Rows[dgvPowerSavingsReport.Rows.Add()]; Hogan

        B Offline
        B Offline
        bwood2020
        wrote on last edited by
        #3

        Thank you for your reply. I have done this but it is still not working. How I have it set up is I add a new row to the grid before I bind the data. The new row contains combo boxes and these combo boxes hold new field headers. After selecting a new header I have a button that, when the user clicks, is suppose to format the columns based on the new header name. For instance, a date needs to be formatted as mm/dd/yyyy. I also have a method that loops through and stores the names in an array then try and format the columns based of the headers name. This part works but doesn't reformat the date. Any ideas?

        S 1 Reply Last reply
        0
        • B bwood2020

          Thank you for your reply. I have done this but it is still not working. How I have it set up is I add a new row to the grid before I bind the data. The new row contains combo boxes and these combo boxes hold new field headers. After selecting a new header I have a button that, when the user clicks, is suppose to format the columns based on the new header name. For instance, a date needs to be formatted as mm/dd/yyyy. I also have a method that loops through and stores the names in an array then try and format the columns based of the headers name. This part works but doesn't reformat the date. Any ideas?

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

          Here is a quick though. Why don't you format the date before you bind the data to the grid. That way it is what you need it to look like and no formatting is required in the grid? If you need to sort still, then make a hidden column of DateTime type and use it for sorting. Hogan

          B 1 Reply Last reply
          0
          • S snorkie

            Here is a quick though. Why don't you format the date before you bind the data to the grid. That way it is what you need it to look like and no formatting is required in the grid? If you need to sort still, then make a hidden column of DateTime type and use it for sorting. Hogan

            B Offline
            B Offline
            bwood2020
            wrote on last edited by
            #5

            Hello, This is a great thought however I have no idea what fields I will be receiving and how they are named. The tool I am developing will allow me to take any file with any header and standardize it before it goes into a system. The files I receive are really messy and you never know what you are going to get and at what position the headers are in. therefore, I would need to import the dataset into the app, apply the new headers then format. Thanks again for the reply. Any ideas on how I could do this or maybe improve or modify the existing code to get the app to do what I need it to do?

            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