473,503 Members | 1,691 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datagrid cell - How to de-select a cell

Hello,
Can someone tell me how you de-select (un select) the currently selected
cell in a datagrid?
Thanks
Nov 15 '05 #1
5 15124
I've tried dataGrid.Unselect(row), I've tried setting the Focus() to another
control, I ve tried dataGrid.Select(row) to select another row...nothing
unselects the currently selected cell. Can someone please assist?
Thanks
"Randy" <None> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Hello,
Can someone tell me how you de-select (un select) the currently selected
cell in a datagrid?
Thanks

Nov 15 '05 #2

Hi Randy,

Thanks for posting in this group.
If you want to de-select current selected row, you can use UnSelect method:
private void button1_Click(object sender, System.EventArgs e)
{
MessageBox.Show(dataGrid1.CurrentRowIndex.ToString ());
dataGrid1.UnSelect(dataGrid1.CurrentRowIndex);
}

If you want to change the current cursor focus to another cell, you can set
DataGrid's CurrentCell property.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #3
Thanks Jeffrey,
There must be some other Window thing going on...I've tried both of these
and no luck...the same cell stays selected. I'll keep plugging along. Thanks
for your help.
""Jeffrey Tan[MSFT]"" <v-*****@online.microsoft.com> wrote in message
news:Vj**************@cpmsftngxa07.phx.gbl...

Hi Randy,

Thanks for posting in this group.
If you want to de-select current selected row, you can use UnSelect method: private void button1_Click(object sender, System.EventArgs e)
{
MessageBox.Show(dataGrid1.CurrentRowIndex.ToString ());
dataGrid1.UnSelect(dataGrid1.CurrentRowIndex);
}

If you want to change the current cursor focus to another cell, you can set DataGrid's CurrentCell property.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #4
Oh, one last question...I have the UnSelect in the MouseDown event...right
before leaving this function. Is there another place this should go? Maybe
I've got it in the wrong area and something is stepping on it?
Thanks

"Randy" <None> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Thanks Jeffrey,
There must be some other Window thing going on...I've tried both of these
and no luck...the same cell stays selected. I'll keep plugging along. Thanks for your help.
""Jeffrey Tan[MSFT]"" <v-*****@online.microsoft.com> wrote in message
news:Vj**************@cpmsftngxa07.phx.gbl...

Hi Randy,

Thanks for posting in this group.
If you want to de-select current selected row, you can use UnSelect

method:
private void button1_Click(object sender, System.EventArgs e)
{
MessageBox.Show(dataGrid1.CurrentRowIndex.ToString ());
dataGrid1.UnSelect(dataGrid1.CurrentRowIndex);
}

If you want to change the current cursor focus to another cell, you can

set
DataGrid's CurrentCell property.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


Nov 15 '05 #5

Hi Randy,

Thanks for your feedback.
Oh, I think the problem should be the time you invoke UnSelect and set
CurrentCell property.
If you change the selected row or selected cell in MouseDown event, the
mouse will reselect you clicked row or cell. So it appears that your code
has no effect.
I think you should add your code in MouseUp event, do like this:

private void dataGrid1_MouseUp(object sender,
System.Windows.Forms.MouseEventArgs e)
{
dataGrid1.CurrentCell= new DataGridCell(0,0); //set the selected cell to
first cell
}

or

private void dataGrid1_MouseUp(object sender,
System.Windows.Forms.MouseEventArgs e)
{
dataGrid1.UnSelect(dataGrid1.CurrentRowIndex);
}

If you still have anything unclear, please feel free to tell me.

Btw: Have good year beginning!

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
6587
by: Jack | last post by:
Mi ingles es peor que el de Toro Sentado, espero que en espaƱol haya alguien capaz de entenderme y orientarme Trabajo con Visual Studio 2003 y C#, he creado un control derivado de datagrid y he...
4
5334
by: Glenn Owens | last post by:
I have a DataGrid web control which I've dynamically populated with template columns to be used for bulk-editting. Generally, all of the columns are textbox and/or dropdownlist child controls. ...
1
4141
by: iforsyth | last post by:
Have a paging datagrid with a checkbox control in column(0). ViewState is enabled. I check the checkbox in first row of the grid on a page and then the program hits this event: Private Sub...
1
1625
by: wh1974 | last post by:
I'm not sure if i'm heading in the right direction so would appreciate any comments on what I'm trying to do. Basically I have a DataGrid on a page which has columns whose width's I set in the...
1
2353
by: Luis Esteban Valencia | last post by:
Hello. I have a datagird with textboxes on a column item template, I also have 2 other columns that are hidden and I want to retrieve his value. But I havent found how to do it. Thanks very much...
9
1572
by: A P | last post by:
Hi! I have created a sample datagrid that can update data on a database. Please help me solve the problem, I have attached both aspx and code behind (aspx.vb): ______________________ ...
2
2832
by: Tim::.. | last post by:
Hi I'm trying to create a little application that shows an image of a user when you mouseover there details in a datagrid. The datagrid is populated from an Active Directory Database and I...
1
4610
by: Tim Newton | last post by:
Hi Anyone tell me how to number the rowheaders of a datagrid, e.g. 1,2,3,4,5 etc, just like in excel. I could put the row numbers in a new column but there has to be a simple way of adding it to...
4
2544
by: steve | last post by:
Hi, First my apologies for double-posting but I am not sure wether this is a VB.Net or TSQL problem. I have the following problem: I generate a T-SQL string in order to fill my Dataset and...
3
1250
by: David | last post by:
Hi all, This is a weird one. I have been asked to look at an intermittent fault. Basically, I have a webservice that is delivering info into a datagrid. Dim Statement As New...
0
7084
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7278
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7458
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5013
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1512
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.