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. help in datagride view CellLeave

help in datagride view CellLeave

Scheduled Pinned Locked Moved C#
help
4 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.
  • A Offline
    A Offline
    aahamdan
    wrote on last edited by
    #1

    Dear Experts, I have datagridView with tow columns. I use the below code to get value from Cell the cursor left, but when cursor left for first time, even if I filled a value, the message box give me "Blank" notjing, but if I returned to the cell and leave it again, then message give me the Value. I have searched in google, but with no result.

    private void dataGridView1_CellLeave(object sender, DataGridViewCellEventArgs e)
    {
    string x = (string)dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;

            MessageBox.Show(x);
    
        }
    

    Your help please. Ahmad,

    S M 2 Replies Last reply
    0
    • A aahamdan

      Dear Experts, I have datagridView with tow columns. I use the below code to get value from Cell the cursor left, but when cursor left for first time, even if I filled a value, the message box give me "Blank" notjing, but if I returned to the cell and leave it again, then message give me the Value. I have searched in google, but with no result.

      private void dataGridView1_CellLeave(object sender, DataGridViewCellEventArgs e)
      {
      string x = (string)dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;

              MessageBox.Show(x);
      
          }
      

      Your help please. Ahmad,

      S Offline
      S Offline
      Sascha Lefevre
      wrote on last edited by
      #2

      Just subscribe to the CellValueChanged[^]-event instead of the CellLeave-event.

      If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

      1 Reply Last reply
      0
      • A aahamdan

        Dear Experts, I have datagridView with tow columns. I use the below code to get value from Cell the cursor left, but when cursor left for first time, even if I filled a value, the message box give me "Blank" notjing, but if I returned to the cell and leave it again, then message give me the Value. I have searched in google, but with no result.

        private void dataGridView1_CellLeave(object sender, DataGridViewCellEventArgs e)
        {
        string x = (string)dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;

                MessageBox.Show(x);
        
            }
        

        Your help please. Ahmad,

        M Offline
        M Offline
        Muhammad Waqas Aziz
        wrote on last edited by
        #3

        put datagridview1.EndEdit() above string x = (string)dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value; statement

        A 1 Reply Last reply
        0
        • M Muhammad Waqas Aziz

          put datagridview1.EndEdit() above string x = (string)dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value; statement

          A Offline
          A Offline
          aahamdan
          wrote on last edited by
          #4

          It is working, Thank you :)

          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