Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

DataGridview Text box cell focus

Last post 05-08-2008 3:57 PM by Kumar. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 05-08-2008 11:19 AM

    • Kumar
    • Not Ranked
    • Joined on 09-05-2002
    • New Member
    • Points 15

    DataGridview Text box cell focus

     Hi

         How to set the cursor focus(Blinking cursor) on the DataGridView Text box Cell in C#.Net.Thanks in advance.
     

    • Post Points: 10
  • 05-08-2008 12:00 PM In reply to

    • moizmala
    • Not Ranked
    • Joined on 05-08-2008
    • India
    • New Member
    • Points 15

    Re: DataGridview Text box cell focus

    Hi Kumar, 

    You can do this thing in two ways:

    1) When you have set the datasource of the grid and executed GridName.DataBind(). Then there is event of the grid as ItemDataBound. You need to map the e object of the method agrument to the cell position where your textbox is. Then declare a textbox object and cast it with the object position found as FindControl like this:

    TextBox txtTemp = new TextBox(); 

    txtTemp = (TextBox)e.Items.Cells(0).FindControl("txtName");

    soon you have that object casted in the txtTemp then set the focus in it.

    If (txtTemp != null)

    { txtTemp.Focus(); }

     2) If you have already populated the grid, then loop through the grid and retrieve the row object of the looped row. Find the mapped position as above and set the focus.

    Regards,

     Moiz

    • Post Points: 5
  • 05-08-2008 3:57 PM In reply to

    • Kumar
    • Not Ranked
    • Joined on 09-05-2002
    • New Member
    • Points 15

    Re: DataGridview Text box cell focus

     Hi Moiz

            Thanks for your quick reply.I will apply it and let you know.

    With thanks

    Kumar
     

       
     

    • Post Points: 5
Page 1 of 1 (3 items)