There is a bug when cell is set as hyperlink, but there is only one row of data, then when you hover above hyperlink, cursor does not change into hand, but stays default. With two or more data rows everything works as expected. I'm not sure if same behaviour is exposed with ObjectListView.
Meanwhile I kind of found a way to do what was needed, but I wont implement it finally. I used the WM_PAINT message, and check what's the "upload region" at that moment, and also if I'm currently over a group header.
Then, if all conditions where met I could just stop the process (not sending the usual MyBase.WndProc)
It works but I really dont like to add so much work in this important message (WM_PAINT), so I wont use it.
If you find anything else, maybe some undocumented code, I'll be glad to know
Phillip Piper www.bigfoot.com/~phillip_piper email@example.com
A man's life does not consist in the abundance of his possessions
Great control, I love it. I suppose my point was that in your otherwise excellent guide (Step 1.1), the setup instructions are almost guaranteed not to work, since any default project in VS2010 uses the Client Profile and the ObjectListView uses the Full framework. Unfortunately the VS2010 error when this happens is next to useless.
Even a single comment/line at the end of that section 1.1 pointing to the FAQ would save a lot of time and needless fiddling.
I have the control as a general component on my form and I have it populating with multiple different objects depending which item the user clicks in the menu. When I change from one object list to another I run the objectlistview.clear method to remove all columns/objects from the list then re-populate the list. if the list is sorted by clicking one of the headers when the list is cleared and new objects are added I get an InvalidCastException when running the "objectlistview.GetColumn(0).Aspectgetter = Function(x) myobject.myProperty". Any suggestions? Am I supposed to clear something else or is this a bug?
Thank you for your help and amazing work on this control.
Below is a sample of the code I run after the list view is cleared.
OLVColumn col1 = new OLVColumn("Name", "Name");
col1.FillsFreeSpace = true;
olvCurrentItems.GetColumn(0).AspectGetter = x => ((Data.Barn)x).Name;
When using ObjectListView, you must use the OLV-specific properties, such as "AllColumns" instead of the ListView-specific properties, which are inherited (e.g. Columns). ObjectListView works differently. OLV is doing a lot of things internally and the inherited ListView properties may have unexpected values or behaviours if you use them.
It could be that you're using more ListView-specific properties within your code. If you could post the relevant code, we may be able to spot them. What you're trying to do should indeed work. You may just have to do things in a slightly different order or use slightly different methods to avoid the exception. Otherwise, perhaps you *have* stumbled onto a bug...
Before I add anything in the ObjectListView I first clear it by running the ObjectListView.Clear method.
this removes all objects and columns
then I add my columns using the following code:
OLVColumn col1 = new OLVColumn("AccountID", "ID");
col1.Width = 120;
OLVColumn col2 = new OLVColumn("Name", "Name");
col2.Width = 150;
OLVColumn col3 = new OLVColumn("Email", "Email");
col3.Width = 150;
OLVColumn col4 = new OLVColumn("Phone1", "Phone");
col4.Width = 100;
OLVColumn col5 = new OLVColumn("Phone2", "Phone");
col5.Width = 100;
olvCurrentItems.GetColumn(0).AspectGetter = x => ((Data.Vendor)x).AccountID;
olvCurrentItems.GetColumn(1).AspectGetter = x => ((Data.Vendor)x).Name;
olvCurrentItems.GetColumn(2).AspectGetter = x => ((Data.Vendor)x).Email;
olvCurrentItems.GetColumn(3).AspectGetter = x => ((Data.Vendor)x).Phone1;
olvCurrentItems.GetColumn(4).AspectGetter = x => ((Data.Vendor)x).Phone2;
the only thing that I'm doing semi out of the ordinary is loading the objects via a separate thread. It doesn't seem like the objectListView cares if it is invoked or not when settingObjects. I assumed since it did not throw an exception that it was already invoked at that point.
OK, I haven't built a mini app to test your code but I can see a couple things right away that may make a difference. Clear is a ListView method. You should call olv.ClearObjects() to remove all objects and then olv.AllColumns.Clear() (I believe) to remove all OLVColumns. That may be the key here. Then you can proceed to add new OLVColumns to the olv.AllColumns collection. Try that and let me know how it goes.
Last Visit: 31-Dec-99 18:00 Last Update: 12-Jul-14 2:04