Accessing data based on grid selected row

G

Guest

I have a grid bound to a dataview. I want the user to be able to select a
cell, then in the menu select 'description' which would show a messagebox
containing a description of the item in that row. The description is in a
hidden column on the selected row. I can't seem to retrieve the dataview
information based on the selected row in the datagrid. How can I do this?
 
I

Ilya Tumanov [MS]

I've noticed VB developers tend to (over/miss) use message boxes a lot
without realizing they drive users completely insane.

You can not copy data from them and you have to push the button every time
it pops up - absolutely terrible.



In this case it's probably way better to add a "Description" tab with big
message box for description and bind it to the same data view so it would be
updated automatically.



Anyway, if you'd like to carry out your original message box idea, here's
how to access selected row:



dataView(dataGrid.CurrentRowIndex)("ColumNameOrIndex")


--
Best regards,

Ilya

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

*** Want to find answers instantly? Here's how... ***

1. Go to
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.compactframework?hl=en
2. Type your question in the text box near "Search this group" button.
3. Hit "Search this group" button.
4. Read answer(s).
 
G

Guest

In this case the description will rarely be needed. The screen space taken
by the tabs won't be worth it.

Anyway, I had already tried what I think is the C# equivalent to what you
suggested:
dataRow = dataView.Table.Rows[dataGrid.CurrentRowIndex]

But my problem was that dataRow was assigned the row indexed by the DataSet,
once I applied a filter and sort to dataView, the results returned were
incorrect.

Anyway, I 'solved' the problem by adding a 0-width description column to the
grid.

Thanks,

Rob
 
I

Ilya Tumanov [MS]

No, that is not the equivalent. Your code would access rows in DataTable
disregarding DataView.

And you're correct; row index in DataTable can be different from row index
in DataView due to sorting and filtering.



Here's how to get correct DataRow:



dataRow = dataView[dataGrid.CurrentRowIndex].Row;



--
Best regards,

Ilya

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

*** Want to find answers instantly? Here's how... ***

1. Go to
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.compactframework?hl=en
2. Type your question in the text box near "Search this group" button.
3. Hit "Search this group" button.
4. Read answer(s).

Rob Morriss said:
In this case the description will rarely be needed. The screen space
taken
by the tabs won't be worth it.

Anyway, I had already tried what I think is the C# equivalent to what you
suggested:
dataRow = dataView.Table.Rows[dataGrid.CurrentRowIndex]

But my problem was that dataRow was assigned the row indexed by the
DataSet,
once I applied a filter and sort to dataView, the results returned were
incorrect.

Anyway, I 'solved' the problem by adding a 0-width description column to
the
grid.

Thanks,

Rob

Ilya Tumanov said:
I've noticed VB developers tend to (over/miss) use message boxes a lot
without realizing they drive users completely insane.

You can not copy data from them and you have to push the button every
time
it pops up - absolutely terrible.



In this case it's probably way better to add a "Description" tab with big
message box for description and bind it to the same data view so it would
be
updated automatically.



Anyway, if you'd like to carry out your original message box idea, here's
how to access selected row:



dataView(dataGrid.CurrentRowIndex)("ColumNameOrIndex")


--
Best regards,

Ilya

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

*** Want to find answers instantly? Here's how... ***

1. Go to
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.compactframework?hl=en
2. Type your question in the text box near "Search this group" button.
3. Hit "Search this group" button.
4. Read answer(s).
 
G

Guest

Ah, perfect. Thanks again!

Ilya Tumanov said:
No, that is not the equivalent. Your code would access rows in DataTable
disregarding DataView.

And you're correct; row index in DataTable can be different from row index
in DataView due to sorting and filtering.



Here's how to get correct DataRow:



dataRow = dataView[dataGrid.CurrentRowIndex].Row;



--
Best regards,

Ilya

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

*** Want to find answers instantly? Here's how... ***

1. Go to
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.compactframework?hl=en
2. Type your question in the text box near "Search this group" button.
3. Hit "Search this group" button.
4. Read answer(s).

Rob Morriss said:
In this case the description will rarely be needed. The screen space
taken
by the tabs won't be worth it.

Anyway, I had already tried what I think is the C# equivalent to what you
suggested:
dataRow = dataView.Table.Rows[dataGrid.CurrentRowIndex]

But my problem was that dataRow was assigned the row indexed by the
DataSet,
once I applied a filter and sort to dataView, the results returned were
incorrect.

Anyway, I 'solved' the problem by adding a 0-width description column to
the
grid.

Thanks,

Rob

Ilya Tumanov said:
I've noticed VB developers tend to (over/miss) use message boxes a lot
without realizing they drive users completely insane.

You can not copy data from them and you have to push the button every
time
it pops up - absolutely terrible.



In this case it's probably way better to add a "Description" tab with big
message box for description and bind it to the same data view so it would
be
updated automatically.



Anyway, if you'd like to carry out your original message box idea, here's
how to access selected row:



dataView(dataGrid.CurrentRowIndex)("ColumNameOrIndex")


--
Best regards,

Ilya

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

*** Want to find answers instantly? Here's how... ***

1. Go to
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.compactframework?hl=en
2. Type your question in the text box near "Search this group" button.
3. Hit "Search this group" button.
4. Read answer(s).

I have a grid bound to a dataview. I want the user to be able to select
a
cell, then in the menu select 'description' which would show a
messagebox
containing a description of the item in that row. The description is
in a
hidden column on the selected row. I can't seem to retrieve the
dataview
information based on the selected row in the datagrid. How can I do
this?
 

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