File tree Expand file tree Collapse file tree 1 file changed +11
-9
lines changed
Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -162,36 +162,38 @@ private void Vcc_ValueChangedEvent(object sender, EventArgs e)
162162
163163 SourceGrid . Cells . ICellVirtual getItemAtGridPoint ( Point P , out int foundrow , out int foundcol )
164164 {
165- int y = 0 ;
166- int y2 = 0 ;
167165 foundrow = 0 ;
166+ foundcol = 0 ;
167+
168+ // Calculate the row index based on the Y position
169+ int y = 0 ;
168170 foreach ( GridRow row in grid1 . Rows )
169171 {
170- y2 = y + row . Height ;
172+ int y2 = y + row . Height ;
171173
172174 if ( P . Y > y && P . Y < y2 )
173175 {
174176 foundrow = row . Index + grid1 . VScrollBar . Value ;
177+ break ;
175178 }
176179 y = y2 ;
177180 }
178181
182+ // Calculate the column based on the X position
179183 int x2 = 0 ;
180- foundcol = 0 ;
181184 int outofview = 0 ;
182185 for ( int i = 0 ; i < grid1 . HScrollBar . Value ; i ++ )
183186 {
184- outofview += grid1 . Columns . GetWidth ( i ) ;
187+ x2 += grid1 . Columns . GetWidth ( i ) ;
185188 }
186-
187189 x2 = - outofview ;
190+
188191 foreach ( GridColumn col in grid1 . Columns )
189192 {
190-
191-
192- if ( P . X > x2 )
193+ if ( P . X > x2 && P . X <= x2 + col . Width )
193194 {
194195 foundcol = col . Index ;
196+ break ;
195197 }
196198 x2 += col . Width ;
197199 }
You can’t perform that action at this time.
0 commit comments