By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,550 Members | 1,733 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,550 IT Pros & Developers. It's quick & easy.

Rows 12 thru 24 are selected in a datagrid. How do I tell when the user selects rows 45 thru 70 ???

P: n/a
I'm using Net 1.1 (2003) SP1 & Windows 2000

Here's the issue ...

Rows 12 thru 24 are selected in a datagrid.

The user now unselects rows 12 thru 24 and selects rows 45 thru 70 ???

How can I tell that the user has reselected a different set of rows in a
datagrid.

I don't see any events at all associated with row selection within a
datagrid.

Thanks in advance!

Barry
in Oregon
Nov 16 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Hi Barry,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to know what's the event that
is fired when selection in a datagrid has changed. If there is any
misunderstanding, please feel free to let me know.

As far as I know, there is only event fired when the first row of the
selection changes. We can handle CurrencyManager.PositionChanged event to
achieve this. Here is an example:

private void Form1_Load(object sender, System.EventArgs e)
{
CurrencyManager cm =
(CurrencyManager)this.BindingContext[this.dataSet11.Employees];
cm.PositionChanged +=new EventHandler(cm_PositionChanged);
}

private void cm_PositionChanged(object sender, EventArgs e)
{
this.Text = this.dataGrid1.CurrentRowIndex.ToString();
}

However, this only works on the scenario that the first row of the
selection changes. For example, the user changes selection from 12 thru 24
to 45 thru 70. But if he changes 12 thru 24 to 12 thru 18, it will not be
fired.

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #2

P: n/a
Kevin,

Thanks for your prompt reply, its very much appreciated. I was hoping that
the datagrid had a better method for tracking when a user highlights a
different set of rows within a datagrid. Oh, well.

With your help here and your answer to my "c# Winforms DataGrid: What's the
difference between highlighted and selected rows ???" question I think I can
set up a mechanism that will allow me to accomplish what I'm trying to do.

Thanks again.

Barry
in Oregon

"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:sK**************@cpmsftngxa10.phx.gbl...
Hi Barry,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to know what's the event that
is fired when selection in a datagrid has changed. If there is any
misunderstanding, please feel free to let me know.

As far as I know, there is only event fired when the first row of the
selection changes. We can handle CurrencyManager.PositionChanged event to
achieve this. Here is an example:

private void Form1_Load(object sender, System.EventArgs e)
{
CurrencyManager cm =
(CurrencyManager)this.BindingContext[this.dataSet11.Employees];
cm.PositionChanged +=new EventHandler(cm_PositionChanged);
}

private void cm_PositionChanged(object sender, EventArgs e)
{
this.Text = this.dataGrid1.CurrentRowIndex.ToString();
}

However, this only works on the scenario that the first row of the
selection changes. For example, the user changes selection from 12 thru 24
to 45 thru 70. But if he changes 12 thru 24 to 12 thru 18, it will not be
fired.

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #3

P: n/a
Kevin,

Thanks for your prompt reply to this and my 2nd question, its very much
appreciated. I was hoping that the datagrid had a better method for
tracking when a user highlights a different set of rows within a datagrid.
Oh, well.

With your help here and your answer to my "c# Winforms DataGrid: What's the
difference between highlighted and selected rows ???" question I think I can
set up a mechanism that will allow me to accomplish what I'm trying to do.

Thanks again.

Barry
in Oregon

P.S. it's very early in the morning here and I mixed up replies to your
responses, I hope you'll fogive me. Best wishes.
"BBFrost" <barry.b.frost@remove_this.wrd.state.or.us> wrote in message
news:#d**************@TK2MSFTNGP10.phx.gbl...
Kevin,

Thanks for your prompt reply, its very much appreciated. I was hoping that the datagrid had a better method for tracking when a user highlights a
different set of rows within a datagrid. Oh, well.

With your help here and your answer to my "c# Winforms DataGrid: What's the difference between highlighted and selected rows ???" question I think I can set up a mechanism that will allow me to accomplish what I'm trying to do.

Thanks again.

Barry
in Oregon

"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:sK**************@cpmsftngxa10.phx.gbl...
Hi Barry,

First of all, I would like to confirm my understanding of your issue. From your description, I understand that you need to know what's the event that is fired when selection in a datagrid has changed. If there is any
misunderstanding, please feel free to let me know.

As far as I know, there is only event fired when the first row of the
selection changes. We can handle CurrencyManager.PositionChanged event to achieve this. Here is an example:

private void Form1_Load(object sender, System.EventArgs e)
{
CurrencyManager cm =
(CurrencyManager)this.BindingContext[this.dataSet11.Employees];
cm.PositionChanged +=new EventHandler(cm_PositionChanged);
}

private void cm_PositionChanged(object sender, EventArgs e)
{
this.Text = this.dataGrid1.CurrentRowIndex.ToString();
}

However, this only works on the scenario that the first row of the
selection changes. For example, the user changes selection from 12 thru 24 to 45 thru 70. But if he changes 12 thru 24 to 12 thru 18, it will not be fired.

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."


Nov 16 '05 #4

P: n/a
Hi Barry,

I think the names of methods lead to misunderstanding. Actually Selected
means the row that mouse is pushed down. The all the rows with blue
backgroud color are highlighted. IsSelected method actually mean
IsHighlighted.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #5

P: n/a
Thanks Kevin,

That's the understanding that I finally reached. I finally ended up passing
thru the data grid 2 times. The 1st time I tagged the 'highlighted' rows
and the 2nd pass I operated on the 'tagged' rows.

Best wishes.

Barry
in Oregon
"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:rF**************@cpmsftngxa10.phx.gbl...
Hi Barry,

I think the names of methods lead to misunderstanding. Actually Selected
means the row that mouse is pushed down. The all the rows with blue
backgroud color are highlighted. IsSelected method actually mean
IsHighlighted.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #6

P: n/a
You're welcome, Barry,

Thanks for sharing your experience with all the people here. If you have
any questions, please feel free to post them in the community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.