How do you get the selected cell of a gridview?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: How do you get the selected cell of a gridview?

  1. #1
    Join Date
    Dec 2012
    Posts
    5

    How do you get the selected cell of a gridview?

    I would like to know how to get the selected cell of a gridview, like for example if a gridview has 4 rows of 4 buttons each, how do you tell if you are clicking button 1 row 1 or button 3 row 4?

    Please dont direct me to MSDN or other such sites, I cant understand them and dont find them useful at all.

  2. #2
    Join Date
    Dec 2012
    Posts
    4

    Re: How do you get the selected cell of a gridview?

    You do something like: -

    DataGridView dv;

    dv.CurrentCell = new DataGridViewCell(row_index, col_index);

  3. #3
    Join Date
    Dec 2012
    Posts
    5

    Re: How do you get the selected cell of a gridview?

    Thanks but that doesnt look like it would get the cell your clicking on, it looks more like it would set it.

  4. #4
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: How do you get the selected cell of a gridview?

    Personally i prefer to use the Repeater, as it includes a few extra options by default and also can be easily formatted to show data anyway you please.. It does take a little extra to setup, but personally i find it worth the work..

    The Gridview by default only returns the current row but not the current column.. there are methods to hack a similar sort of functionality into the Gridview, but that would require links to MSDN and such, also none seem to really return the specific column you clicked on, but rely on scanning through the cells for markers or changes...

    Now what specifically are you trying to achieve, then perhaps i can spot you some code and pointers to complete this..
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center