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. Grid View Column

Grid View Column

Scheduled Pinned Locked Moved C#
helpcssquestion
5 Posts 3 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.
  • M Offline
    M Offline
    Mahdi_kishislan
    wrote on last edited by
    #1

    i create control and this control derived from gridview control.then i add 2 column in constructor like this : InitializeComponent(); this.AutoGenerateColumns = false; DataGridViewCheckBoxColumn cb = new DataGridViewCheckBoxColumn(); cb.HeaderText = ""; cb.Name = "dgvcSelect"; this.Columns.Add(cb); DataGridViewTextBoxColumn tb = new DataGridViewTextBoxColumn(); tb.Name = "dgvcRowNumber"; tb.HeaderText = "ردیف"; but when i run my program 4 column generate for me.where is the problem? please help me

    D P 2 Replies Last reply
    0
    • M Mahdi_kishislan

      i create control and this control derived from gridview control.then i add 2 column in constructor like this : InitializeComponent(); this.AutoGenerateColumns = false; DataGridViewCheckBoxColumn cb = new DataGridViewCheckBoxColumn(); cb.HeaderText = ""; cb.Name = "dgvcSelect"; this.Columns.Add(cb); DataGridViewTextBoxColumn tb = new DataGridViewTextBoxColumn(); tb.Name = "dgvcRowNumber"; tb.HeaderText = "ردیف"; but when i run my program 4 column generate for me.where is the problem? please help me

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Did you turn AutoGenerateColumns back on in your code consuming this new control? Do your column names match the column names coming from your bound data?

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak

      M 1 Reply Last reply
      0
      • D Dave Kreskowiak

        Did you turn AutoGenerateColumns back on in your code consuming this new control? Do your column names match the column names coming from your bound data?

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak

        M Offline
        M Offline
        Mahdi_kishislan
        wrote on last edited by
        #3

        some column come from database but these 2 column generate at runtime.i think thic part of code call twice.what can i do when i have custom control and want generate columns at runtime?

        D 1 Reply Last reply
        0
        • M Mahdi_kishislan

          some column come from database but these 2 column generate at runtime.i think thic part of code call twice.what can i do when i have custom control and want generate columns at runtime?

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          If you think that's the case, then call the Clear method of the Columns collection at the start of your code that setups up your columns.

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak

          1 Reply Last reply
          0
          • M Mahdi_kishislan

            i create control and this control derived from gridview control.then i add 2 column in constructor like this : InitializeComponent(); this.AutoGenerateColumns = false; DataGridViewCheckBoxColumn cb = new DataGridViewCheckBoxColumn(); cb.HeaderText = ""; cb.Name = "dgvcSelect"; this.Columns.Add(cb); DataGridViewTextBoxColumn tb = new DataGridViewTextBoxColumn(); tb.Name = "dgvcRowNumber"; tb.HeaderText = "ردیف"; but when i run my program 4 column generate for me.where is the problem? please help me

            P Offline
            P Offline
            phani raavi
            wrote on last edited by
            #5

            Please find this example. write the select query what ever the colums you want to display in datagridview http://www.dotnetsharepoint.com/2013/07/display-data-in-datagridview-c.html#.UfEm342fjwg[^]

            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