By Thomas Holste - 7/9/2011
Hi there,
after a while I started working on my new app again and encountered some
problems I can't solve by myself. I started an app which uses the
strataframe listview which really impresses me because of the wonderful
layout/design-options but I got two problems where I need some help.
At first I'd like to tell you that the listview is populated by adding item with
the listview.items.add-method.
The first problem is, that I can not navigate with the up- and down-keys
through the list. I had a look at your listview-samples, navigating with up-
and down-key doesn't work there too. Am I doing something wrong or do
I have to implement this by myself. If yes, how is this done?
The second problem ist that I haven't figured out yet how to determine
the position within the list which is currently selected. For example say
that the listview has 15 items, how do I determine the selected item?
I checked all properties and their values in the debugger, but haven't
found a way yet.
Thanks a lot for your help and best regards
Thomas
|
By Edhy Rijo - 7/9/2011
Hi Thomas,
For the first problem, I frankly don't know the answer. Probably the Up/Down navigation is not supported. A while ago, the SF team released a beta for a new Enhanced Listview which is much faster and has more features that the standard SF listview, but all population is done manually which may not be an issue with you.
Trent posted a sample application here which will give you more details on how to populate the StrataListView. Be aware that some of the automation build in the standard SF listview are not yet implemented in the StrataListView.
For the second problem, you should be using one of the listview population methods instead using the Item.Add(). When the SF listview is bounded to a Business Object, some nice automation can be done like automatically moving the record pointer on the BO assigned to the listview, so when you navigate the listview you can make a reference to any property to its BO and you will be in the record that was selected in the listview.
There are many samples and thread about both listviews to help you compare with your code and use them as designed to take advantage of the whole SF framework. I love SF Listview, but when you need to load over thousand records, then the StrataListview will just fly over the standard one, performance is very noticeable.
|
By Thomas Holste - 7/10/2011
Hi Edhy,
Thanks for your answer, sorry, I should have been more precise. What I use is not the Listview but the stratalistview-control. I loaded the stratalistview-samples but the up- and down-keys don't work there too. But I am wondering why something so basic as moving through the list with keys should not be supported?
The use of BOs for this little app would be so much overhead because what the app does basically is that it receives delimited text-records, splits the fields in an array and adds some of them to a stratalistview-item with header and footer. Thats all, first filling a BO, just to get the index of a record seems not really necessary to me.
If there is no keyboard-support, adding it could be done by me if I had an answer for the problem how to determine (and setting) the index of a highlighted row.
Best regards
Thomas
|
By Ivan George Borges - 7/10/2011
Hi Thomas.
The standard StrataFrame listview will let you use the arrow keys for navigation. Up to now I hadn't noticed the StrataListView wouldn't.
And for the selected value, you could use the listview "Tag" to store any value you want to fetch later, and then on the ListView.SelectedIndexChanged method and test on your ListView.SelectedItems(0).Tag value.
|
By Thomas Holste - 7/10/2011
Hi Ivan,
thanks for your answers
<<The standard StrataFrame listview will let you use the arrow keys for navigation. Up to now I hadn't noticed the StrataListView wouldn't.>>
It would be good and save me some time to definitely know, if the stratalistview supports the arrow-keys (and something might be wrong here) or not. And if not, if this will be implemented in the near future.
<<And for the selected value, you could use the listview "Tag" to store any value you want to fetch later, and then on the ListView.SelectedIndexChanged method and test on your ListView.SelectedItems(0).Tag value. >>
I already thought about that but how do I set an Index or to say it in other words how do I select a special item from outside the grid? For example: If I had to do the key-handling by myself, I would start on Position 1. Now a user presses the arrow-down key and I have to set the selected item to Position 2. Or presses PageDown and I would have to select the last position? How can I do this?
Thanks in Advance and best regards
Thomas
|
By Edhy Rijo - 7/10/2011
Thomas Holste (7/10/2011) I already thought about that but how do I set an Index or to say it in other words how do I select a special item from outside the grid? For example: If I had to do the key-handling by myself, I would start on Position 1. Now a user presses the arrow-down key and I have to set the selected item to Position 2. Or presses PageDown and I would have to select the last position? How can I do this?
Hi Thomas,
If I understand you correctly, you really don't need to set any index for the selected item. When you implement the Up/Down feature, the listview will keep track of the selected index which will be reported in the ListView.SelectedIndexChanged, just by using the code Ivan suggested will always get you the selected item in the list which you can identify in your BO or your table if you previously updated the .Tag property with the PK value you can later reference to your record.
Even thought you may consider overkill to use a BO, whatever you may loose may be worthy if it will make your development process and code easier. BO are very useful to manipulate the data and unless you are dealing with many thousands of records, IMHO there is not a realistic penalty in performance. I have applications that deals with thousands of records and a lot of data manipulations and the BO features like GetEnumerable, Filter, Seek, Navigate, CopyDataFrom just to mention a couple, makes my life easier with much less code than just using a native data table with twice or triple the code needed to handle the data manipulation.
At this point, if you still having issues with the StrataListView, I would suggest you post a basic sample where we can take a look and help you with the implementation you need. Since I don't know when new updates will be released from the SF team, I even went ahead and added some functionality from the old listview by simply looking at its source code and implement some of them in the new one, nothing perfect but at least workable for my project until new updates are available, you can find the post here: http://forum.strataframe.net/FindPost28459.aspx
|
By Thomas Holste - 7/10/2011
Hi Edhy
thanks for your suggestions but I can not really understand what you mean by writing this:
<< When you implement the Up/Down feature, the listview will keep track of the selected index which will be reported in the ListView.SelectedIndexChanged, just by using the code Ivan suggested will always get you the selected item in the list which you can identify in your BO or your table if you previously updated the .Tag property with the PK value you can later reference to your record.>>
Lets get a little bit more example like
1. I Add Items to a stratalistview and set an index-value in the tag-property of each item. If I have 10 items i start with 1 and finish with 10 ( or 0 to 9).
2. If I change the selected item I can get the value of the tag-property. This is what I understand from Ivans proposal.
This is all clear, but what do I have to do something like this:
1. Let's say the selected item tag is 1. The user wants to press the down-arrow-key to change the selected
item to the next item in the stratalistview (to simple skip through the item-list.
To do this, as I understand it, there should be some code in
the keypress-event of the stratalistview (or form with key-preview) which handles the keypress in a way like that:
if keypressed = DownArrowkey
' what has to happen here to skip through the stratalistview?
Endif
Using a BO might be possible, but before I add an additional layer of complexity to a relative simple way of presenting data (No need to do anything than showing this data, which is not some kind of database but just plain ansi-data) I first would like to know what is possible and what not with the stratalistview. If it is clearly designed just to work with BOs, I accept this and would have to consider using a BO or using another tool for that specific task which would be a pity because of the wonderful visual appearance of the stratalistview with its possibilities of Header and footer subitems which is really useful for this special task.
Best regards
Thomas
|
By Edhy Rijo - 7/10/2011
Hi Thomas, Like I said before, I cannot help you adding the functionality of Up/Down because I have not done that before, and I am not a member of the SF team. All I know is that this control was released under beta and is not feature completed so only the SF team can provide a more direct answer of what features will this control be able to handle.
Now, knowing what what we know about the control, I would suggest the following:
- Look at the source code of the standard listview and see if the Up/Down feature is implemented and try to add that functionality to the StrataListView, if you have any issues, post the sample application here and we all can try to help out, or
- Wait for somebody from the SF team to address this post, probably this functionality has already been implemented and not released.
|
By Edhy Rijo - 7/10/2011
Hi Thomas,
A quick look at the StrataListView source code reveals that they added code to handle the Key.Up/Down but the code in the OnKeyUp event is commented out, so either they had an issue with the code or something else.
With this information you can either subclass the StrataListView as I had done and try to implement the OnKeyUp and the ManageKeyStroke() method or just wait for the SF team response.
In case you have not found out yet, StrataListView is in the MicroFour StrataFrame UI Expanded project in the "Controls WinForm" folder.
Here is the commented code:
/// <summary> /// Look for certain key combinations on the up /// </summary> /// <param name="e"></param> protected override void OnKeyUp(KeyEventArgs e) { base.OnKeyUp(e); //-- START HERE AGAIN FOR KEYBOARD IMPLEMENTATION ////-- Check for valid key strokes //if(e.KeyCode == Keys.Down || // e.KeyCode == Keys.Up) //{ // ManageKeystroke(e); //} //-- Reset the ctrl key _IsCtrlDown = false; }
|
By Thomas Holste - 7/11/2011
Hi Edhy,
thanks a lot for your tips which made things a bit clearer for me.
I hadn't realised that stratalistview is a beta-version, which explains to me why such a basic thing like keyboard navigation is not implemented. To implement some keyboard-handling like you suggested seems to be easy but I am getting to the point where I would like to wait for some answer from the SF-Team what seems to be the securest thing. Without knowing what direction the stratalistview might take it is a bit unsafe for me to work with a subclassed control which is in beta. And adding the keyboard-handling does not help me finding out how to navigate within the list. I will surely try a BO, but would definitely prefer to use it in unbound mode. But as this app is just a side-project, I will wait what the SF-Teams will say about keyboard-handling and index-based selecting an item.
Best regards
Thomas
|
By Ivan George Borges - 7/11/2011
Hey Thomas.
It makes sense, but while that have you considered using the standard StrataFrame ListView?
|
By Thomas Holste - 7/11/2011
Hi Ivan,
I do not consider using the Listview control as it has not the display-possibilities of the stratalistview-control. What really attracts me is the ability of displaying header and footer text like it does and that's why I tried it and am still trying to use it. What I would like to know is, if it is planned to add keyboard-support for skipping through items or if that is not an issue for the near future? In that case I will have to try some other control for that app.
Best regards
Thomas
|
By Thomas Holste - 7/15/2011
Hi there,
I did not give up and this is it what seems to work. I post it in case anyone else wants to use the
statalistview in unbound mode.
If e.KeyCode = Keys.Down Then
Dim nPos As Integer
Dim nLast As Integer
Dim nNext As Integer
' Get number of items
nLast = LV.Items.Count - 1
' Get index-position of selected item
nPos = LV.Items.IndexOf(LV.SelectedItems(0))
nNext = nPos + 1
If nLast > -1 And nNext <= nLast Then
' Set index to next possible position
LV.Items.Item(nNext).Selected = True
' Ensure that the display "moves" along the index-setting
LV.EnsureVisible(LV.Items.Item(nNext))
End If
End If
This is just a first version but it works. If anyone knows problems which could emerge with this kind of code, please tell me.
Best regards
Thomas
|
|