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. Focus on custom Cell when entering a Row in DataGridView

Focus on custom Cell when entering a Row in DataGridView

Scheduled Pinned Locked Moved C#
helpquestion
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.
  • F Offline
    F Offline
    freshonlineMax
    wrote on last edited by
    #1

    Hi I have a DataGridview control. I want that, when user enters in NewRow I fill some cells with default values and Focus on costum cell. But i got an Error : (Operation is not valid because it results in a reentrant call to the SetCurrentCellAddressCore function.) And my code : private void dGridViewWork_RowEnter(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == dGridViewWork.Rows.Count-1) { dGridView.Rows[e.RowIndex].Cells[0].Value = "1001"; dGridView.Rows[e.RowIndex].Cells[4].Value = true; dGridView.CurrentCell = dGridViewWork[1, e.RowIndex]; //Error dGridView.BeginEdit(true); } } An error refers to the line that Focuses on Cell[1,x]. Can you help me? Tanx.

    K 1 Reply Last reply
    0
    • F freshonlineMax

      Hi I have a DataGridview control. I want that, when user enters in NewRow I fill some cells with default values and Focus on costum cell. But i got an Error : (Operation is not valid because it results in a reentrant call to the SetCurrentCellAddressCore function.) And my code : private void dGridViewWork_RowEnter(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == dGridViewWork.Rows.Count-1) { dGridView.Rows[e.RowIndex].Cells[0].Value = "1001"; dGridView.Rows[e.RowIndex].Cells[4].Value = true; dGridView.CurrentCell = dGridViewWork[1, e.RowIndex]; //Error dGridView.BeginEdit(true); } } An error refers to the line that Focuses on Cell[1,x]. Can you help me? Tanx.

      K Offline
      K Offline
      Keshav V Kamat 0
      wrote on last edited by
      #2

      I did not get what you meant by that exactly. Still assuming that you are trying to access the row 1. By default you can access only the 1st (0th row). i u want to access, you need to add more rows. else you will get error when you refer to the first row, or any cell from that row, i.e. Cell[1,x]. Still please tell me more about it.

      Keshav Kamat :) India

      F 1 Reply Last reply
      0
      • K Keshav V Kamat 0

        I did not get what you meant by that exactly. Still assuming that you are trying to access the row 1. By default you can access only the 1st (0th row). i u want to access, you need to add more rows. else you will get error when you refer to the first row, or any cell from that row, i.e. Cell[1,x]. Still please tell me more about it.

        Keshav Kamat :) India

        F Offline
        F Offline
        freshonlineMax
        wrote on last edited by
        #3

        Hi and Tanx Dear friend Cell[1,x] means Cell[ColumnIndex,RowIndex]. I know it's funny but when we want to set CurrentCell we first type columnindex. For example imagine we are at Row number 6 (Last Row) and user press Enter key. DataGridView create new blank row, Now i want to set First Cell's value to 7 programmatically and automatically move cursor to Second cell, then goto input mode . But there is an Error in focussing to second cell in 'RowEnter Event'. Please Help.

        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