StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      


12»»

Is there any way to change the selected row...Expand / Collapse
Author
Message
Posted 09/05/2008 3:57:55 PM
StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: 12/20/2008 1:55:52 PM
Posts: 149, Visits: 206
Hi All.

The reason that I want to do this is necause I am using a context menu to allow them to add, edit and delete item (it calls up a modal dialog). It is a little confusing to them if they right click, select edit or delete, and the information from a different row shows up in the modal dialog.

TIA

Post #19123
Posted 09/05/2008 4:05:25 PM
Advanced StrataFrame User

Advanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame User

Group: StrataFrame Users
Last Login: Today @ 4:05:52 PM
Posts: 760, Visits: 3,282
Hi Marcia,

I believe you are using a datagrid to display the data.  If you don't need to modify the data in the grid and will use a modal form, I strongly suggest you use a ListView, this control have been greatly enhanced to support this type of presentation to the end user and it is pretty easy to setup, the StrataFlix Movie form (I believe that is the name) make use of this so you can examine and start using right away.

When I first started with SF and coming from VFP I tried to use a datagrid, but if the data in the grid/listview will be readonly, then nothing beats the listview enhancements in version 1.6.6.

 
Post #19124
Posted 09/05/2008 4:14:38 PM
StrataFrame Team Member

StrataFrame Team Member

Group: StrataFrame Users
Last Login: 12/23/2008 11:10:40 AM
Posts: 232, Visits: 511
Yep, 100% agree with Edhy on this one. The listview can't be beat in most situations. There are still those areas where you need a grid, but you'd be surprised how robust a listview can be while still keeping the interface and design fairly simple.

To answer your question, however, you can use the Navigate, Move, or Seek methods of the business object to change the CurrentRowIndex of the business object. Navigate will update any bound controls to reflect the new CurrentRowIndex, while Move and Seek move the CurrentRowIndex pointer without updating any bound controls.

So for your grid, on a right click you could do a SeekToPrimaryKey(primaryKeyOfClickedRow) to move the CurrentRowIndex of your BO before doing the edit or delete.

Post #19125
Posted 09/05/2008 5:01:26 PM
StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: 12/20/2008 1:55:52 PM
Posts: 149, Visits: 206
Edhy Rijo (09/05/2008)
Hi Marcia,

When I first started with SF and coming from VFP I tried to use a datagrid, but if the data in the grid/listview will be readonly, then nothing beats the listview enhancements in version 1.6.6.

Since I practically have this working the way I want, I will take that advice in the future and refactor this form after I have enoough cranked out to show the client at our next meeting

Thanks for the advice.

Post #19137
Posted 09/05/2008 5:03:02 PM
StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: 12/20/2008 1:55:52 PM
Posts: 149, Visits: 206
Dustin Taylor (09/05/2008)

So for your grid, on a right click you could do a SeekToPrimaryKey(primaryKeyOfClickedRow) to move the CurrentRowIndex of your BO before doing the edit or delete.

Color me stupid, but I do not see any RightClick event in the DataGridView that I can handle

If you can tell me where it is, I would be happy to hook into it

Post #19138
Posted 09/05/2008 5:08:25 PM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: 12/09/2008 3:36:08 PM
Posts: 2,686, Visits: 1,891
It's probably called MouseClick or PreviewMouseClick.  The event args will tell you which button(s) was clicked to raise the event.


www.bungie.net
Post #19140
Posted 09/05/2008 5:10:45 PM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: 12/09/2008 3:36:08 PM
Posts: 2,686, Visits: 1,891
Yep, MouseClick is the general one.  There's also a bunch of Mouse* methods like MouseDown and MouseUp you can handle.  Also, the grid has CellClick and CellDoubleClick, and ones like ColumnHeaderMouseClick and ColumnHeaderMouseDoubleClick.  Almost all of those will have MouseEventArgs which will tell you the mouse button that was used.  Just test on e.Button == MouseButtons.Right or something like that in your handler and you should be in business.


www.bungie.net
Post #19141
Posted 09/05/2008 6:11:32 PM
StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: 12/20/2008 1:55:52 PM
Posts: 149, Visits: 206
Ben Chase (09/05/2008)
It's probably called MouseClick or PreviewMouseClick.  The event args will tell you which button(s) was clicked to raise the event.

Yes. I found that event. What I couldn't find was a way to set the SelectedRow in the grid.

Post #19145
Posted 09/05/2008 8:10:01 PM
Advanced StrataFrame User

Advanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame User

Group: StrataFrame Users
Last Login: Today @ 4:05:52 PM
Posts: 760, Visits: 3,282
Marcia G Akins (09/05/2008)
Yes. I found that event. What I couldn't find was a way to set the SelectedRow in the grid.

The time and effort you are putting on the grid is good for learning, but taking a 10 minute look at the listview in StrataFlix will give you all the things you are trying to do manually and much more. 

Trust me I've been there, and did the same thing until I understood that the SF listview is not like the one in VFP which I hardly used.

 
Post #19147