We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to tell one cell is selected?

Thread ID:





27103 Apr 6,2005 01:40 PM UTC Apr 6,2005 02:22 PM UTC WinForms 3
Tags: GridControl
Philip Bishop
Asked On April 6, 2005 01:40 PM UTC

Im trying to find the best or easiest way to tell if one cell is selected. I''ve asked this in the past but I wanted to make sure there wasnt any other ways to do this. I want to be able to tell if the user has clicked ONE and only one cell. So what we came up with today was the following Dim MySelectedRanges As New GridRangeInfoList grdREPA.Selections.GetSelectedRanges(MySelectedRanges, True) Then I check the count of myselectedranges and if its equal 1 then i know i either have one cell selected or i have a ONE range of cells selected. Then i take that further to check myselectedranges.info and if it has a colon(r1c1:r2c2) in it then i know that there is more then one cell. If there is no colon(r1c1), then i know its only one cell in the range selected. Is this the easiest or best way to do this??

Administrator [Syncfusion]
Replied On April 6, 2005 02:04 PM UTC

Do you have grid.ExcelLikeCurrentCell set to true? This setting affects what is selected.

Philip Bishop
Replied On April 6, 2005 02:10 PM UTC

Yes I do

Administrator [Syncfusion]
Replied On April 6, 2005 02:22 PM UTC

Here is how I would try this. It is probably close to what you are doing. I think the code will work whether or not you have ExcelLikeCurrentCell set, and whether or not your grid has a currentcell at all. Whether it is any better than what you are doing, I am not sure.
public bool OnlyCurrentCellSelected()
	GridRangeInfoList rangeList = grid.Selections.Ranges;
	bool b = grid.CurrentCell.HasCurrentCell && 
			(rangeList.Count == 0 
			|| (rangeList.Count == 1
				&& grid.ExcelLikeCurrentCell
				&& rangeList.ActiveRange == grid.CurrentCell.RangeInfo
	return b;


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon