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. Bound DataGridView with unbound text box column

Bound DataGridView with unbound text box column

Scheduled Pinned Locked Moved C#
cssquestion
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.
  • N Offline
    N Offline
    Nigel Mackay
    wrote on last edited by
    #1

    The DGV is bound to a table. I have an inserted TextBoxColumn which is meant to display values from a related table. I have my grid displaying nicely, with the empty text box column. I have the values to insert into the grid. But when do I do it? With which event handler? I saw a suggestion to use DataBindingsComplete, but the column hasn't been inserted by the time that is called. EDIT: Just had a thought. Don't auto-generate the columns. Manually create all the columns. Then add the rows, one-by-one, populating the columns as I go.

    L 1 Reply Last reply
    0
    • N Nigel Mackay

      The DGV is bound to a table. I have an inserted TextBoxColumn which is meant to display values from a related table. I have my grid displaying nicely, with the empty text box column. I have the values to insert into the grid. But when do I do it? With which event handler? I saw a suggestion to use DataBindingsComplete, but the column hasn't been inserted by the time that is called. EDIT: Just had a thought. Don't auto-generate the columns. Manually create all the columns. Then add the rows, one-by-one, populating the columns as I go.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Nigel Mackay wrote:

      With which event handler?

      Depends on "how" you'd want to do so. One option would be the CellFormatting[^] event. Get's called whenever the value of a cell is needed. Check if the cell is in the last column, and if so, fetch the value - otherwise, display the default.

      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

      N 1 Reply Last reply
      0
      • L Lost User

        Nigel Mackay wrote:

        With which event handler?

        Depends on "how" you'd want to do so. One option would be the CellFormatting[^] event. Get's called whenever the value of a cell is needed. Check if the cell is in the last column, and if so, fetch the value - otherwise, display the default.

        Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

        N Offline
        N Offline
        Nigel Mackay
        wrote on last edited by
        #3

        Yes, that would work. In fact it rings a bell from many years ago, along with CellValueNeeded and CellValuePushed. Because I only have 2 bound and 1 unbound column and the grid is Read Only I created the grid manually. That way I can populate the grid while it is being built.

        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