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

B

BBFrost

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
 
K

Kevin Yu [MSFT]

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."
 
B

BBFrost

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
 
B

BBFrost

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 said:
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 said:
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."
 
K

Kevin Yu [MSFT]

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."
 
B

BBFrost

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
 
K

Kevin Yu [MSFT]

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."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top