|
|
Comments and Discussions
|
|
 |

|
Hi,
I'm using the TreeListView to display data, but the data is refreshed by an updating interval. So always when data is refreshed, the treeListView is completley collapsed.
I tried with this, but it doesn't work:
var expanded = treeListView1.ExpandedObjects;
treeListView1.SetObjects(data);
foreach (var exp in expanded)
{
treeListView1.Expand(exp);
}
How can i do this ?
Thanks in advance,
Mondkind93
|
|
|
|

|
Hi,
i have a ObjectListView control with many more columns, about 20.
The db query is very fast, but when i set data using SetObjects ( this.objectListView1.SetObjects((List)result, true); ), to see the data in the control i have to wait about a minute.
Anybody can help me ?
Thanks in advance.
Giuseppe.
|
|
|
|

|
20 columns is not an unusual amount of columns. 200 would be a lot.
As with all performance issues, a profiler is your best friend. JetBrains and Redgate both have excellent profilers.
Questions:
* What flavour of ObjectListView are you using?
* How many rows are you loading? Typical performance of a plain ObjectListView on a low-end machine should be about 1000 rows per seconds.
* Have you tried taking out columns progressively to see if it is one column in particular that is causing trouble?
Regards,
Phillip
------------------------------------------------------------------------
Phillip Piper www.bigfoot.com/~phillip_piper phillip.piper@gmail.com
A man's life does not consist in the abundance of his possessions
|
|
|
|

|
Thanks for answer, i will investigate further
Giuseppe
|
|
|
|

|
Hi,
i need to reposition the selection over the current selected row after reloading or sorting the grid items.
I tried with SelectedObject without fortune.
How can i do this ?
Thanks in advance,
Giuseppe.
|
|
|
|

|
Same question. I've been looking all over for the answer to this question. When I get the SelectedObject, reset my DataSource, and then call SelectObject, the OLVListItem is null and I lose my selection. My code:
object bs = _cellDLV.SelectedObject;
_cellDLV.DataSource = LoadDataSet();
if (bs != null)
{
_cellDLV.SelectObject(bs, true);
}
Thanks for any tips,
David
|
|
|
|

|
ObjectListView uses Equals() to determine which objects are equal. When you call SelectObject(), ObjectListView tries to find an object in the list is equal to the given object.
Almost certainly, the originally selected object is no longer in the list. So, trying to select it will do nothing.
To remember the selection, you will have to add an Equals() method to your object, or remember its "unique key" that will still be the same after you have reloaded the data set.
Regards,
Phillip
------------------------------------------------------------------------
Phillip Piper www.bigfoot.com/~phillip_piper phillip.piper@gmail.com
A man's life does not consist in the abundance of his possessions
|
|
|
|

|
Thank you. I just found another thread in this forum in which you answered a similar question. Sorry I didn't find it sooner.
Thanks again,
David
|
|
|
|

|
For all those out there using ObjectListView for the first time, I strongly recommend reading the section entitled Unlearn You Must on the official OLV page.
The most important points here are:
1) OLV is not a drop-in replacement for a regular .NET ListView
2) Do not use the regular ListView properties and methods. Use the OLV equivalents and extras instead.
3) Do not use ListViewItems. Generally, you will not need to change anything in the list directly. OLV uses a model-centric approach, which means it will handle most of the view state internally.
FYI
|
|
|
|

|
Very good advice
------------------------------------------------------------------------
Phillip Piper www.bigfoot.com/~phillip_piper phillip.piper@gmail.com
A man's life does not consist in the abundance of his possessions
|
|
|
|

|
Hi,
I'm using following statement to retrieve a value from a cell(datalistview):
this.dlvData.Items[this.dlvData.SelectedIndex].SubItems[1].Text;
This works perfectly but I would like to call the cell value by key, like this:
this.dlvData.Items[this.dlvData.SelectedIndex].SubItems["olvColumn01"].Text;
This gives null, any idea how to call the cell value by key/name instead of using the index.
Thanks in advance for the support.
Benjamin
|
|
|
|

|
SubItems["string"] gets the value of the subitem with a string key, not necessarily the value of any particular column.
In general, you should not be using (or even need to use) regular ListView methods & properties, as these are not guaranteed to be in sync with the ObjectListView internals. Use ObjectListView methods instead, such as olv.Objects intead of olv.Items and olv.SelectedObjects instead of olv.SelectedItems.
Since your OLV should be using model objects, why not simply ask the object what its value is instead of prodding the view directly?
e.g. instead of
this.dlvData.Items[this.dlvData.SelectedIndex].SubItems["olvColumn01"].Text;
use something like
MyModel model = (MyModel)dlvData.SelectedObject;
string text = model.FirstName;
|
|
|
|

|
Hello,
first of all thank you for your reply.
this.dlvData.Items[this.dlvData.SelectedIndex].SubItems["olvColumn01"].Text;
This code never works for me, that's my question on the first place, if this would work, my problem was solved. => Always returns null for the moment.
I 've always used instead of the key the index and it has never failed me. But the problem is when you add a new column => you can start to count all over => is not a good solution.
The method you mention is new to me and I don't get it to work.
What exactly is Mymodel in your example? Could you please give me an example with my parameters(see below)?
I'll try to explain more what I want to do:
I have a datalistview with property fillrowselect = true and no multiple selections allowed. The user can click a row and click on a button for example. Then the idea is to retrieve the values from the selected row and do some things with it.
So I have: dlvData is my datalistview
olvColumnName is a column with string content
olvColumnActive is a column with a boolean content
so how can I use your method to do this:
string strName = this.dlvData.Items[this.dlvData.SelectedIndex].SubItems[1].Text;
boolean blnActive = Convert.ToBoolean(this.dlvData.Items[this.dlvData.SelectedIndex].SubItems[2].Text);
Thanks in advance for your help.
Best regards,
Benny
|
|
|
|

|
I'll admit that I don't have much experience using OLV's DataListView, but the methodology should be the same. You use an OLV to display a view of some model object and its properties.
Remember, dlv.Items is a regular ListView member and it is not guaranteed to do exactly what you want. Instead, use an ObjectListView member, such as "SelectedObject".
DataRowView row = (DataRowView)dlv.SelectedObject;
string name = (string)row["Name"];
bool isActive = (bool)row["IsActive"];
How are you populating your list? It's possible that DataListView is not the most appropriate type of OLV for your situation. For example, using a regular ObjectListView, which you populate with objects of a class MyModel that you specify, the above could become:
MyModel model = (MyModel)olv.SelectedObject;
string name = model.Name;
bool isActive = model.IsActive;
Use whatever makes sense to you, but one of the goals of OLV is to do a lot of the work for you so that you don't HAVE to poke and prod directly at the ListView or its ListViewItems and ListViewSubItems.
|
|
|
|

|
Thank you very much for your help. This was exactly what I wanted to achieve.
Much better then my method.
I've learned a lot from your explanation and example here.
Best regards,
Benjamin
|
|
|
|

|
This control has helped me a great deal, so I'm pleased to help others with it when I can
|
|
|
|

|
I have been chasing a bug for several days that gives me; "...is not a parameter-less method, property.." as text in my subitem. I thought this was a C# error but found nothing on Google, so searching for the text found it in OLV Munger.cs. It seems that on a certain OLV column that if I use an AspectName I get this error instead of the text that should be in that field. If I remove the AspectName then I just get a blank field, instead of my data. There does not seem to be anything unique about the column, but it will not show the data (that is confirmed to pass into OLV), where all the other columns work as designed.
Anyone got any suggestions?
Thanks
modified 24 Apr '13 - 7:29.
|
|
|
|

|
If you get the "...is not a parameter-less method, property or field of type..." warning, then it's exactly that--the Aspect you've used does not exist in your model object. e.g. if your Aspect is "FirstName", then make sure your model object contains a "FirstName" property, field, or parameterless method, i.e. model.FirstName. Remember also that this is case sentitive. If your Aspect is deeper, e.g. for a "car" model, Engine.Oil.IsEmpty, make sure every entity along the way exists. In any case, there must be something very subtly wrong in your aspect name.
|
|
|
|

|
Thanks for that feedback. As it turns out i'm not using Aspects at all. I put a name in the properties field because I discovered that if I left that property field empty no data would be printed into sub- items, so I added a simple unique name in each column, but don't use it.
Just tried removing All aspect names, but just got an (null) printed to control and nothing else.
this bug has got me stumped.
thanks
|
|
|
|

|
If you're using an ObjectListView, then you probably should be using aspect names on each of your columns. This is the OLV's flagship way of automagically putting the value of your model objects' properties, etc. into the columns/cells of the list view. You can do this from the Designer or from code, but if your columns are static and you created them in the designer, then you probably should put the aspect name in there at the same time.
public class MyModel
{
public string FirstName { get; set; }
public string LastName { get; set; }
public MyModel(string first, string last)
{
this.FirstName = first;
this.LastName = last;
}
}
public void SomeInitializationMethod()
{
FirstNameColumn.AspectName = "FirstName";
LastNameColumn.AspectName = "LastName";
}
public void AddItems()
{
MyModel model1 = new Model("John", "Smith");
MyModel model2 = new Model("Jane", "Doe");
myOlv.AddObject(model1);
myOlv.AddObject(model2);
}
|
|
|
|

|
I confirmed every Aspect has been given a string name in the designer. I'm back to the "...parameter-less..." message again. Looking at your code its a bit different than the online example. Here is what I do to load ObjectListView;
watchlist.Add(new ConnectionInfo( sDeviceName, IPAddress, Connected, disconnected, Alert, deviceType));
objectlstConnectionList.SetObjects(watchlist);
You add objects one at a time and I add a list one time when the list is completed. I verify the list is complete with no NULLs or any missing data in any field.
Thanks
|
|
|
|

|
The error message should tell you everything you need to know.
If the message is:
* 'SomeMethod' is not a parameter-less method, property or field of type 'SomeType'
then:
* "SomeMethod" is the text you entered into the AspectName of the column. This should be the name of a property on your model object.
* "SomeType" is the type of your model object that you added to ObjectListView.
If you post the whole error message, it might be easier to see what is going wrong.
Please, please, please read the Getting Started page.
Regards,
Phillip
------------------------------------------------------------------------
Phillip Piper www.bigfoot.com/~phillip_piper phillip.piper@gmail.com
A man's life does not consist in the abundance of his possessions
|
|
|
|

|
I created my app from the example app given in the Getting Started page. I love the idea you guys have pushed forward here, but Dang has this issue been a bear to resolve.
The error I receive is printed in several cells of my OLV and is;
"DeviceIP is not a parameter-less method, property or field of type Dashboard.child_class.ConnectionInfo"
The LIST that I feed to the OLV is a simple 6 string list.
I made this simple example app and it gives the error too;
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public List<ConnectionInfo> watchlist = new List<ConnectionInfo>( );
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
AddToWatchedDeviceList2("device name", "99.222.33.44", "saturday", "sunday", "-", false, "controller");
}
public void AddToWatchedDeviceList2(string sDeviceName, string IPAddress, string Connected, string disconnected,
string Alert, bool emailChecked, string deviceType)
{
watchlist.Add(new ConnectionInfo( sDeviceName, IPAddress, Connected, disconnected, Alert, deviceType));
objectlstConnectionList.SetObjects(watchlist);
}
}
public class ConnectionInfo
{
public string DeviceName{ get; set; }
public string IpAddress { get; set; }
public string LastConnection { get; set; }
public string LastDisconnected{ get; set; }
public string Alerts { get; set; }
public string DeviceType { get; set; }
public ConnectionInfo(string deviceName, string ipaddress, string connected, string disconnected, string alert,
string deviceType)
{
DeviceName = deviceName;
IpAddress = ipaddress;
LastConnection = connected;
LastDisconnected = disconnected;
Alerts = alert;
DeviceType = deviceType;
}
}
}
|
|
|
|

|
The property name in your ConnectionInfo class is "IpAddress" but the aspect name it's complaining about is "DeviceIP". The aspect name MUST match a member name from your class or else you'll get the error as described.
|
|
|
|

|
First off... THANK YOU!!! I don't want to think about how many hours a chased that issue.
Second.... OMG... could that be any more subtle. The error msg maybe could use a little revision for clarity. perhaps something like... "Hey you idiot, your aspectname does not match your class parameter name", or something to that extent.
thanks again
|
|
|
|

|
In desperation I just removed the OLV from project and then added it back again. I still get the error message, but now its in a completely different column. If none of my code changed, and I only removed the OLV and then put it back on the form in [Design], then that would indicate what?
thanks
|
|
|
|

|
Hi, I have a graphical bug with OLV.
I use several image in a OLV. All of this images have the same size, but some images are resized and some images not.
In this screen capture, the TV logo and the HDTV logo are the same size but the HDTV logo is resized and become very blurry !
http://img694.imageshack.us/img694/917/guidedelutilisateurmozi.png[^]
I don't know if it's a OLV bug, Windows bug or .NET bug. If someone can help me...
|
|
|
|

|
Did all the images come from the same format? Same dimensions? I'd check to make sure the size & maybe even bit depth are consistent and what you expect. If the sizes are a bit off, it could skew the resultant image.
|
|
|
|

|
All images are 26x26 size, PNG format (bit depth unknown, I will look this evening) , from Icon8.
I use them in a VB Project and images are in Resource.
|
|
|
|
|

|
What is the row height in your OLV? Does it match the height of the image (26px)? At least if it does, you can rule resizing out as a possible cause.
|
|
|
|

|
If this problem is only occurring in one image, that image is likely to be the problem.
Try duplicating an image that currently works and using that instead of the image that is giving problems. If the duplicated image work, just edited it so it shows the actual image you want.
Regards,
Phillip
------------------------------------------------------------------------
Phillip Piper www.bigfoot.com/~phillip_piper phillip.piper@gmail.com
A man's life does not consist in the abundance of his possessions
|
|
|
|
|

|
Excellent. Glad to hear
|
|
|
|

|
I have use this control for times, and when I update the dll from 2.4.0 to 2.5.1, it looks some stranges:
If you use TreeListView, and set like these:
treeListView1.CheckBoxes = true;
OLVColumn col = new OLVColumn();
col.TextAlign = HorizontalAlignment.Right;
treeListView1.Columns.Add(col);
In 2.4.0, whatever you set the TextAlign property, the check box stay on the left,then icon and text.
In 2.5.1, the check box will stay on the right, but both the icon and text still on the left.
modified 28 Mar '13 - 13:02.
|
|
|
|

|
Let me start by thanking you for this wonderful control and second by appreciating you for your patience on some harsh comments. I want to filter the filtered results. For example after searching "x" from list I got 13 results. And from these 13 results, I want to filter "s". Any trick or help.
I wonder if there is any adjustment for Text Highlighter for RightToLeft languages. Because while highlighting text for right to left languages, control start highlighting text from left side of text. For example one wants to search for "ار" from a word "اردو", control should highlight "ار", but instead of "ار" it highlights "دو".
modified 26 Mar '13 - 15:04.
|
|
|
|

|
You've got a couple of options. An ObjectListView has two members which deal with filtering: olv.ListFilter and olv.AdditionalFilter. You could use these two together to indicate your primary and secondary filters (be they the same or different type of filter). A second alternative is, if you want unlimited levels of filtering, to use a CompositeFilter. This will join any number of filters and apply them together. The filters don't even need to be of the same type. In particular, there is a CompositeAllFilter, where a model object needs to satisfy ALL contained filters to be included in the list.
I'm afraid I don't have any immediate help for the right-to-left text highlighting, but you could try poking around the OLV source code in Renderer.cs. Look for the HighlightTextRenderer's render methods. It looks like it's basically drawing a box around the text, starting from the left, up to the size of the matched text. If you can somehow pass this function a parameter telling it whether to start from the left or right, you can probably get it to do what you want. Alternatively, if your application will only be used in a right-to-left language, you could modify the function always to start from the right, build it, and use the modified DLL in your project.
Hope that helps.
|
|
|
|

|
Thanks for your both precious answers. That really helped. I think it is good to add a property in OLV for RightToLeft highlighting at least. When one is using OLV in RightToLeft layout, definitely he need highlighting in RightToLeft as well. Alternatively programer can detect, in which language user is typing and can use RightToLeft highlighting property. It would be great help for beginners like me. Thanks once again.
|
|
|
|
|

|
Hello.
First of all congratulate you on the great control that has placed at our disposal, is exceptionally good.
Second, how can edit the value of a cell from the code, ie, without user intervention?, In my case I have to go through the list and according to the value of a cell to change the value of another.
Thanks in advance
pd. Sorry for my English, isn´t very good
|
|
|
|

|
This is an ObjectListView. The items in your list should represent "model" objects. The value of each cell usually corresponds to a member of your model object. Therefore, when the value of one member changes, you should know which other member also needs to be updated at the same time. Then, all you need to do is refresh that object in ObjectListView, and both cells will be updated.
For example, consider this simple model:
public class Product
{
public string Name { get; set; }
public decimal Price { get; set; }
public int Quantity { get; set; }
public decimal Total { get { return Price * Quantity; } }
}
We also have an ObjectListView called ProductList with four columns, one for each property of our Product model object. In one of the OLV's CellEdit events, you can determine what value is being modified and adjust another value.
private void ProductList_CellEditFinishing(object sender, CellEditEventArgs e)
{
Product model = (Product)e.RowObject;
if (e.Column.AspectName == "Quantity") {
if (model.Quantity >= 10)
model.Price *= 0.8m; ProductList.RefreshObject(model); }
}
Hope that helps.
|
|
|
|

|
Thank you for your prompt response AEronStrife.
I'll see if I can explain a little better:
In my case, the control is a FastDataListView, the data is retrieved using a SQL query and add the control using the DataSource and DataMember, once this is done the user selects the rows you want to update (by check in the records) and combobox selecting a particular value is at the time when you have to loop through the rows of fastdatalistview and if the record is checked, depending on the value of a column, change the contents of another column.
I hope I explained.
Thanks in advance
|
|
|
|

|
I'm not sure I completely understand your situation (and my experience with FastDataListView is limited), but some should still apply. Firstly, if the checkbox is in the first column of your list, then you should be able to use the OLV.CheckedObjects property to get the list of all checked records instead of looping through the entire list. Secondly, if you know which column you are changing and what the new value is, then you should be able to make a change to the contents of another column at the same time. You probablky would not even need an event like I was mentioning before. Perhaps I'm still misunderstanding your situation...
|
|
|
|

|
Very interesting and practically important stuff.
Thank you for sharing.
—SA
|
|
|
|

|
5
(I'd give you 6 if they had it)
Great work!
|
|
|
|

|
Hello,
First, I want to congratulate you (again) for this wonderful component. Been using it for over 3 years now.
I encountered an issue. I want to change the background color of items programatically (not in the format row event).
For example, I want when I click a button, to change the backcolor of an item.
So I do this:
objectListView2.Items[0].BackColor = Color.LightSeaGreen;
wn.objectListView2.Refresh();
If the list is an ObjectListView this works.
If the list is a fastlistview, this does not work.
I am using latest version of the component.
Hope you can help clarify things.
Thanks,
Vlad
|
|
|
|

|
When using ObjectListView, you cannot use the regular ListView methods that interact with items & colums directly. That's because OLV is doing a lot of things for you internally. You must instead use the ObjectListView-specific methods. For example, instead of using listView.Items, you would use a method such as listView.GetItem(). There are numerous examples but this is the general idea.
Since this is an object list view, one way of changing the colour via a button would be to add a field to your model object class to represent the state that the change of colour represents. Perhaps you even have a candidate field already. When you click the button, update the field in the object, call listView.RefreshObject(...), and yes, create a FormatCell / FormatRow event that will take care of the rest for you.
There may be other approaches, but using FormatCell / FormatRow and switching on fields within the model objects is what I use and I believe it's the intended approach with OLV.
|
|
|
|

|
If the collection of ModelObject contains two or more equal objects (IEquatable), then some functions of OLV may work on the wrong object.
It's due to some OLV functions use the function"IndexOf(ModelObject)" that returns the first object found, which may be different from the wished object
|
|
|
|

|
If the "CheckBoxes" property of a OLV is true, then the first cell can't be editable.
[^]
The first column ("Nom") is editable and the "CellEditActivation" is "CELLEDIT_SINGLECLICK".
If I click on the first cell of a row, I can't edit it, but the F2 key start the cell editing but Enter key do not validate the data entry. The edit of other cells is OK.
|
|
|
|

|
Is it possible to have you add icons to the controls? For each release I add some 'standard' icons to the DataListView, DataTreeListView, FastDataListView, etc...
The code bit is simple:
[System.Drawing.ToolboxBitmap(typeof(System.Windows.Forms.ListView))]
public class FastDataListView : FastObjectListView
Sure, I could create a cool Phil Piper icon for said...but at least it adds a bit of clarification when one adds them to the tool bar in VS.
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.
|
An easier to use ListView that supports sorting, grouping, editing, overlays, and drag-n-drop.
| Type | Article |
| Licence | GPL3 |
| First Posted | 17 Oct 2006 |
| Views | 2,557,870 |
| Downloads | 77 |
| Bookmarked | 1,539 times |
|
|