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

DataGrid

Scheduled Pinned Locked Moved C#
question
3 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.
  • R Offline
    R Offline
    Rick Crone
    wrote on last edited by
    #1

    I have a DataGrid in my windows app. One of the fields is a date time type. It's showing up at a date in my DataGrid. I really need to see the time too. How can I change the format of this one field in the DataGrid?

    B 1 Reply Last reply
    0
    • R Rick Crone

      I have a DataGrid in my windows app. One of the fields is a date time type. It's showing up at a date in my DataGrid. I really need to see the time too. How can I change the format of this one field in the DataGrid?

      B Offline
      B Offline
      Burt Harris
      wrote on last edited by
      #2

      To change the format of a column, you need to set the Format property of the DataGridTextBoxColumn corresponding to the column. See the example code under DataGridTextBoxColumn should help. Burt Harris

      R 1 Reply Last reply
      0
      • B Burt Harris

        To change the format of a column, you need to set the Format property of the DataGridTextBoxColumn corresponding to the column. See the example code under DataGridTextBoxColumn should help. Burt Harris

        R Offline
        R Offline
        Rick Crone
        wrote on last edited by
        #3

        Thanks you for your reply. In my application I'm trying to display records in a table that let me know that some services I have written are working. At this point I'm updating the display on a button click. I tried to apply the code I found in the example you pointed me to. You can see the error message from my exception trap. Can you tell me where I when wrong? private void m_btnUpdate_Click(object sender, System.EventArgs e) { this.sqlDataAdapter1.Fill(this.imAliveDataSet1,0,0,"ImAlive"); // Gets the DataGridTextBoxColumn from the DataGrid control. DataGridTextBoxColumn myTextBoxColumn; myTextBoxColumn = null; // Assumes the Time column is a DataGridTextBoxColumn. try { myTextBoxColumn = (DataGridTextBoxColumn)dataGrid1. TableStyles["ImAlive"].GridColumnStyles["Time"]; } catch (Exception excpt) { string strMsg = string.Format("{0} Exception caught.", excpt); } // Gets the DataGridTextBox for the column. DataGridTextBox myGridTextBox; myGridTextBox = (DataGridTextBox) myTextBoxColumn.TextBox; strMsg "System.NullReferenceException: Object reference not set to an instance of an object. at FordMon.Form1.m_btnUpdate_Click(Object sender, EventArgs e) in c:\source\ford\fordmon\fordmon\form1.cs:line 227 Exception caught." string

        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