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 Column Properties

DataGrid Column Properties

Scheduled Pinned Locked Moved C#
helptutorialquestion
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.
  • I Offline
    I Offline
    Idealius
    wrote on last edited by
    #1

    Hi, Can anyone tell me how to change column name and column width for a DataGrid (Windows.Forms) that is not bound to a DataSet (i.e. not using DataGrid.TableStyles?) Thanks in Advance, [EDIT] Actually, I just figured out how to edit the names by accessing my DataTable, and figured out how to create a TableStyle dynamically: DataGridTableStyle myGridTableStyle = new DataGridTableStyle(); However, Help, says you must first create a new DataGridColumnStyle per the table. This: DataGridColumnStyle myGridColumnStyle = new DataGridColumnStyle(); isn't available, though. Compiler error: Cannot create an instance of the abstract class or interface 'System.Windows.Forms.DataGridColumnStyle' So, anyone know how to get around this? I know I have to use DataGridColumnStyle's to change the width of the column, but if I can't create a DataGridColumnStyle I'm at a loss...(And like I said in the original post: no, I can't use the GUI to accomplish this because I'm not using a DataSource via DataSet, etc.) [/EDIT] -Idealius

    S 1 Reply Last reply
    0
    • I Idealius

      Hi, Can anyone tell me how to change column name and column width for a DataGrid (Windows.Forms) that is not bound to a DataSet (i.e. not using DataGrid.TableStyles?) Thanks in Advance, [EDIT] Actually, I just figured out how to edit the names by accessing my DataTable, and figured out how to create a TableStyle dynamically: DataGridTableStyle myGridTableStyle = new DataGridTableStyle(); However, Help, says you must first create a new DataGridColumnStyle per the table. This: DataGridColumnStyle myGridColumnStyle = new DataGridColumnStyle(); isn't available, though. Compiler error: Cannot create an instance of the abstract class or interface 'System.Windows.Forms.DataGridColumnStyle' So, anyone know how to get around this? I know I have to use DataGridColumnStyle's to change the width of the column, but if I can't create a DataGridColumnStyle I'm at a loss...(And like I said in the original post: no, I can't use the GUI to accomplish this because I'm not using a DataSource via DataSet, etc.) [/EDIT] -Idealius

      S Offline
      S Offline
      Stephane Rodriguez
      wrote on last edited by
      #2

      The DataGridColumnStyle class has over 10 abstract methods, thus cannot be instantiated. The compiler lists the methods that need implementation. Either you provide (default) implementation, or you may just as well use one of the two ready-to-use derived classes. In MSDN, click on the DataGridColumnStyle item in the TOC, you'll see the class hierarchy, which lists : DataGridBoolColumn and DataGridTextBoxColumn.

      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