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. Source Grid cell Focus Problem

Source Grid cell Focus Problem

Scheduled Pinned Locked Moved C#
helpcss
6 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.
  • S Offline
    S Offline
    soulidentities
    wrote on last edited by
    #1

    Hi ppl Pls help me with a cell change problem. I have a sourcegrid with 4 column ans 4 rows. I can Insert data to every cell but the problem is I dont wanna use mouse or Tab to change cell. I want to use Enter key to change cell. That mease I will insert data to a cell and press Enter key and coursor will go to next cell. Can anyone have face this problem.... please help me Thanks

    B 1 Reply Last reply
    0
    • S soulidentities

      Hi ppl Pls help me with a cell change problem. I have a sourcegrid with 4 column ans 4 rows. I can Insert data to every cell but the problem is I dont wanna use mouse or Tab to change cell. I want to use Enter key to change cell. That mease I will insert data to a cell and press Enter key and coursor will go to next cell. Can anyone have face this problem.... please help me Thanks

      B Offline
      B Offline
      buachaill cliste
      wrote on last edited by
      #2

      SourceGrid - Open Source C# Grid Control[^] I presume that^ is the source grid you're on about. Something like this should work

      void grid1_KeyDown(object sender, KeyEventArgs e)
      {
      if (e.KeyCode == Keys.Enter)
      {
      if (grid1.FocusCell.Row == grid1.RowsCount-1)
      //to check if you have reached the last cell in the column
      {
      if (grid1.FocusCell.Column == grid1.Columns.Count - 1)//checks if you have reached the
      //last row in the last column
      {
      grid1[1,0].Focus(); selects the first cell
      }
      else grid1[1, grid1.FocusCell.Column + 1].Focus();selects the first cell in the next
      //column
      }
      else grid1[grid1.FocusCell.Row + 1, grid1.FocusCell.Column].Focus();//selects the next cell
      }
      }

      S 1 Reply Last reply
      0
      • B buachaill cliste

        SourceGrid - Open Source C# Grid Control[^] I presume that^ is the source grid you're on about. Something like this should work

        void grid1_KeyDown(object sender, KeyEventArgs e)
        {
        if (e.KeyCode == Keys.Enter)
        {
        if (grid1.FocusCell.Row == grid1.RowsCount-1)
        //to check if you have reached the last cell in the column
        {
        if (grid1.FocusCell.Column == grid1.Columns.Count - 1)//checks if you have reached the
        //last row in the last column
        {
        grid1[1,0].Focus(); selects the first cell
        }
        else grid1[1, grid1.FocusCell.Column + 1].Focus();selects the first cell in the next
        //column
        }
        else grid1[grid1.FocusCell.Row + 1, grid1.FocusCell.Column].Focus();//selects the next cell
        }
        }

        S Offline
        S Offline
        soulidentities
        wrote on last edited by
        #3

        many many thanks. I have tried it but some error I cant understand... void grid1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (grid1.FocusCell.Row == grid1.RowsCount-1) //to check if you have reached the last cell in the column { if (grid1.FocusCell.Column == grid1.Columns.Count - 1)//checks if you have reached the //last row in the last column { grid1[1,0].Focus(); //selects the first cell } else grid1[1, grid1.FocusCell.Column + 1].Focus();//selects the first cell in the next //column } else grid1[grid1.FocusCell.Row + 1, grid1.FocusCell.Column].Focus();//selects the next cell } } The Bold text "grid1.focuscell.row and grid1.focuscell.colume does not have any defination." Cant you fix it pls Thanks

        modified on Tuesday, April 14, 2009 10:18 PM

        A B 2 Replies Last reply
        0
        • S soulidentities

          many many thanks. I have tried it but some error I cant understand... void grid1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (grid1.FocusCell.Row == grid1.RowsCount-1) //to check if you have reached the last cell in the column { if (grid1.FocusCell.Column == grid1.Columns.Count - 1)//checks if you have reached the //last row in the last column { grid1[1,0].Focus(); //selects the first cell } else grid1[1, grid1.FocusCell.Column + 1].Focus();//selects the first cell in the next //column } else grid1[grid1.FocusCell.Row + 1, grid1.FocusCell.Column].Focus();//selects the next cell } } The Bold text "grid1.focuscell.row and grid1.focuscell.colume does not have any defination." Cant you fix it pls Thanks

          modified on Tuesday, April 14, 2009 10:18 PM

          A Offline
          A Offline
          a hamidy
          wrote on last edited by
          #4

          put your source grid name ("grid1" change it to your grid name") there my friend. I think you better use the key up event, that can easly handle enter or arrow keys.

          1 Reply Last reply
          0
          • S soulidentities

            many many thanks. I have tried it but some error I cant understand... void grid1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (grid1.FocusCell.Row == grid1.RowsCount-1) //to check if you have reached the last cell in the column { if (grid1.FocusCell.Column == grid1.Columns.Count - 1)//checks if you have reached the //last row in the last column { grid1[1,0].Focus(); //selects the first cell } else grid1[1, grid1.FocusCell.Column + 1].Focus();//selects the first cell in the next //column } else grid1[grid1.FocusCell.Row + 1, grid1.FocusCell.Column].Focus();//selects the next cell } } The Bold text "grid1.focuscell.row and grid1.focuscell.colume does not have any defination." Cant you fix it pls Thanks

            modified on Tuesday, April 14, 2009 10:18 PM

            B Offline
            B Offline
            buachaill cliste
            wrote on last edited by
            #5

            Sorry that was my fault :^) You must be using version 4; try this way: :-D

            void grid1_KeyUp(object sender, KeyEventArgs e)
            {
            if (e.KeyCode == Keys.Enter)
            {
            int row = grid1.Selection.ActivePosition.Row;
            textBox1.Text = row.ToString();
            int column = grid1.Selection.ActivePosition.Column;
            if (grid1.Selection.ActivePosition.Row == grid1.RowsCount - 1)
            //to check if you have reached the last cell in the column
            {
            if (column == grid1.Columns.Count - 1)//checks if you have reached the last row in the last column
            {
            grid1.Selection.Focus(new SourceGrid.Position(1, 0), true);//selects the very first cell

                            }
                            else grid1.Selection.Focus(new SourceGrid.Position(1, grid1.Selection.ActivePosition.Column + 1), true);//selects the first cell in the next column
                        }
                                
                        else 
                            grid1.Selection.MoveActiveCell(1, 0);
                    }
                }
            
            S 1 Reply Last reply
            0
            • B buachaill cliste

              Sorry that was my fault :^) You must be using version 4; try this way: :-D

              void grid1_KeyUp(object sender, KeyEventArgs e)
              {
              if (e.KeyCode == Keys.Enter)
              {
              int row = grid1.Selection.ActivePosition.Row;
              textBox1.Text = row.ToString();
              int column = grid1.Selection.ActivePosition.Column;
              if (grid1.Selection.ActivePosition.Row == grid1.RowsCount - 1)
              //to check if you have reached the last cell in the column
              {
              if (column == grid1.Columns.Count - 1)//checks if you have reached the last row in the last column
              {
              grid1.Selection.Focus(new SourceGrid.Position(1, 0), true);//selects the very first cell

                              }
                              else grid1.Selection.Focus(new SourceGrid.Position(1, grid1.Selection.ActivePosition.Column + 1), true);//selects the first cell in the next column
                          }
                                  
                          else 
                              grid1.Selection.MoveActiveCell(1, 0);
                      }
                  }
              
              S Offline
              S Offline
              soulidentities
              wrote on last edited by
              #6

              Sorry I was out of town.I have tried it but It didnt work. Dont know why. Do I need to use any event handler code to the .Designer.CS page? Like this.grid1.keypress += new ..... pls make it clear. Thanks again

              modified on Saturday, April 18, 2009 11:24 AM

              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