Click here to Skip to main content
15,908,673 members
Please Sign up or sign in to vote.
1.44/5 (2 votes)
See more:
hi friends
i try to find position of selected cell in gridview c# , but that dont have position property
how can i get it?
please help ... thanks
forgive me for poor English..
Posted
Updated 10-Jun-22 23:57pm
Comments
Sergey Alexandrovich Kryukov 10-Aug-14 1:48am    
First, what do you mean by this "grid view", exactly? Full type name, please. Why knowing the position?
—SA
Ehsanf3 10-Aug-14 1:54am    
sorry..I mean Data GridView in c#... i have a listview and that is invisible , when i select an special cell in data gridview, listview should be visible in that cell position.
Sergey Alexandrovich Kryukov 10-Aug-14 2:20am    
Full name is System.Windows.Forms.DataGridView, not what you've written. I see no need to know a location. You did not even try to explain why.
—SA
Sergey Alexandrovich Kryukov 10-Aug-14 2:21am    
Full name is System.Windows.Forms.DataGridView, not what you've written. I see no need to know a location. You did not even try to explain why.
—SA

try this

C#
list_box.Location = grid_View.PointToScreen(
   grid_View.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false).Location);
 
Share this answer
 
v2
DataGridView1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, False).Location


'to get mouse location
Private Sub DataGridView1_CellMouseClick(sender As Object, e As DataGridViewCellMouseEventArgs) Handles DataGridView1.CellMouseClick
    Dim newpoint As New Point
    newpoint = DataGridView1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, False).Location
    newpoint.X = newpoint.X + e.X
    newpoint.Y = newpoint.Y + e.Y
End Sub
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900