|
Private Function surname(ByVal obj As Object) As Object
Return DirectCast(obj, Person).Surname
End Function
in this code "Person" is the class in which u want to cast or convert you "obj" value so
in you case it may be different..
and
what value u want to return will also be different
like "Surname"
Return DirectCast(obj, Person).Surname
its property of that class..
getting..
|
|
|
|
|
Thanks for the very prompt reply!
Sorry, but I'm struggling with this, would you be so kind as to give an example of the Person class?
Thanks for your help.
Rob
|
|
|
|
|
i was not able to attach files.. so..
Form1.vb---
Imports BinaryComponents.SuperList
Imports BinaryComponents.SuperList.Sections
Imports BinaryComponents.Utility.Collections
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
_superList.MultiSelect = False
Dim surnameColumn As New Column("surname", "Surname", 120, AddressOf surname)
Dim firstnameColumn As New Column("firstname", "Firstname", 120, AddressOf firstname)
Dim phoneColumn As New Column("phone", "Phone", 100, AddressOf phone)
Dim cityColumn As New Column("city", "City", 60, AddressOf city)
Dim stateColumn As New Column("state", "State", 70, AddressOf state)
'Dim dateColumn As New Column("date", "Date", 110, AddressOf ConvertedAnonymousMethod1)
'dateColumn.GroupItemAccessor = New ColumnItemValueAccessor(GroupValueFromItem)
'dateColumn.MoveBehaviour = Column.MoveToGroupBehaviour.Copy
'dateColumn.GroupSortOrder = SortOrder.Descending
surnameColumn.SortOrder = SortOrder.Ascending
_superList.Columns.Add(surnameColumn)
_superList.Columns.Add(firstnameColumn)
_superList.Columns.Add(phoneColumn)
_superList.Columns.Add(stateColumn)
_superList.Columns.Add(cityColumn)
'_superList.Columns.Add(dateColumn)
'_superList.Columns.GroupedItems.Add(dateColumn)
_superList.Columns.GroupedItems.Add(stateColumn)
'AddHandler _superList.SelectedItems.DataChanged, AddressOf SelectedItems_DataChanged
'AddHandler _superList.Click, AddressOf _superList_Click
'int tickStart = Environment.TickCount;
'const int iterationCount = 1; // Change this if you want to increas the number of items in the list
'for( int i = 0; i < iterationCount; i++ )
'{
_superList.Items.AddRange(Person.GetData())
'}
End Sub
Private Function surname(ByVal obj As Object) As Object
Return DirectCast(obj, Person).Surname
End Function
Private Function firstname(ByVal obj As Object) As Object
Return DirectCast(obj, Person).Firstname
End Function
Private Function phone(ByVal obj As Object) As Object
Return DirectCast(obj, Person).Phone
End Function
Private Function city(ByVal obj As Object) As Object
Return DirectCast(obj, Person).City
End Function
Private Function state(ByVal obj As Object) As Object
Return DirectCast(obj, Person).State
End Function
Private Sub _superList_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles _superList.DoubleClick
Dim i As RowIdentifier
For Each i In _superList.SelectedItems
MessageBox.Show(DirectCast(i.Items(0), Person).Firstname)
Next
End Sub
End Class
--- Person.vb---
Imports System
Imports System.Collections
Imports System.Collections.Generic
Imports System.Text
Public Class Person
Inherits CollectionBase
Implements IComparable
Public Sub New(ByVal surname As String, ByVal firstname As String, ByVal phone As String, ByVal city As String, ByVal state As String)
Me.New(surname, firstname, phone, city, state, Nothing)
End Sub
Private Shared _nextId As Integer = 1
Private _id As Integer = System.Math.Max(System.Threading.Interlocked.Increment(_nextId), _nextId - 1)
Public Sub New(ByVal surname As String, ByVal firstname As String, ByVal phone As String, ByVal city As String, ByVal state As String, ByVal dateVal As Date)
Me.Surname = surname
Me.Firstname = firstname
Me.Phone = phone
Me.City = city
Me.State = state
If dateVal = Date.MinValue Then
dateVal = DateTime.Now + New TimeSpan(_randomizer.[Next](0, 1000 * 60 * 60 * 24 * 7))
End If
Me.MyDate = dateVal
End Sub
Private Shared _randomizer As New Random(1)
Public Overloads Overrides Function ToString() As String
Return _id + " " + Me.Firstname + " " + Me.Surname
End Function
Public Surname As String
Public Firstname As String
Public Phone As String
Public City As String
Public State As String
Public MyDate As Date
Private Shared _count As Integer = 0
Public Shared Function GetData() As Person()
Dim persons As Person() = New Person() { _
New Person("Alexander", "Lee", "408 496-7223", "Menlo Park", "CA", DateTime.Now), _
New Person("O'Leary", "Fay", "408 286-2428", "San Jose", "CA", DateTime.Now + New TimeSpan(0, 1, 0, 0)), _
New Person("Alexander", "Sam", "415 986-7020", "Oakland", "CA", DateTime.Now + New TimeSpan(0, 1, 0, 0)), _
New Person("O'Leary", "Jim", "408 286-2428", "San Jose", "CA", DateTime.Now + New TimeSpan(0, 0, 0, 0)), _
New Person("Alexander", "Harry", "415 548-7723", "Berkeley", "CA", DateTime.Now + New TimeSpan(0, 3, 0, 0)), _
New Person("O'Leary", "Jack", "408 286-2428", "San Jose", "CA", DateTime.Now + New TimeSpan(0, 0, 2, 0)), _
New Person("Straight", "Dean", "415 834-2919", "Oakland", "CA", DateTime.Now - New TimeSpan(3, 0, 0, 0)), _
New Person("Smith", "Meander", "913 843-0462", "Lawrence", "KS"), _
New Person("Bennet", "Abraham", "415 658-9932", "Berkeley", "CA"), _
New Person("Dull", "Ann", "415 836-7128", "Palo Alto", "CA"), _
New Person("Gringlesby", "Burt", "707 938-6445", "Covelo", "CA"), _
New Person("Locksley", "Charlene", "415 585-4620", "San Francisco", "CA"), _
New Person("Greene", "Morningstar", "615 297-2723", "Nashville", "TN"), _
New Person("Blotchet-Halls", "Reginald", "503 745-6402", "Corvallis", "OR"), _
New Person("Yokomoto", "Akiko", "415 935-4228", "Walnut Creek", "CA"), _
New Person("del Castillo", "Innes", "615 996-8275", "Ann Arbor", "MI"), _
New Person("DeFrance", "Michel", "219 547-9982", "Gary", "IN"), _
New Person("Stringer", "Dirk", "415 843-2991", "Oakland", "CA"), _
New Person("MacFeather", "Stearns", "415 354-7128", "Oakland", "CA"), _
New Person("Karsen", "Livia", "415 534-9219", "Oakland", "CA"), _
New Person("Panteley", "Sylvia", "301 946-8853", "Rockville", "MD"), _
New Person("Hunter", "Sheryl", "415 836-7128", "Palo Alto", "CA"), _
New Person("McBadden", "Heather", "707 448-4982", "Vacaville", "CA"), _
New Person("Ringer", "Anne", "801 826-0752", "Salt Lake City", "UT"), _
New Person("Ringer", "Albert", "801 826-0752", "Salt Lake City", "UT")}
For Each person As Person In persons
_count += 1
person.Firstname = _count.ToString() + " " + person.Firstname
Next
Return persons
End Function
#Region "IComparable Members"
Public Function CompareTo(ByVal obj As Object) As Integer
Dim p As Person = TryCast(obj, Person)
If p Is Nothing Then
Return -1
End If
Return Me._id - p._id
End Function
#End Region
Public Function CompareTo1(ByVal obj As Object) As Integer Implements System.IComparable.CompareTo
End Function
End Class
-----------------
need to add related reference .. for list list control.. i was not able to link the files.. so...
can any body tell me how to attach files..
|
|
|
|
|
Fantastic!!
I can see how it all fits together now and your examples are BRILLIANT!!
Thank you so much, you are truely the son of god!
Rob
|
|
|
|
|
Hi there,
This a fantastic control! Thanks.
I have been trying to convert the Email preview code to vb but I'm having issues. Could you give me a hand, would be most appreciated.
Thanks again
|
|
|
|
|
Well I would do but the last time I did any VB was with VB 3 which wouldn't be much use, even that knowledge through lack of use has been ejected from my neurons
Maybe someone else can help...
Good luck
Lee
|
|
|
|
|
Thanks for the reply. Any takers?
|
|
|
|
|
I've been looking for this for a long time. All I was able to find was a bunch of bloatware libraries that were very expensive.
Thank you so much for making this available.
Johnny67
|
|
|
|
|
Hi,
Glad you like it, like I said in the article I've always wanted to give something back to this superb site so it's great I've had the opportunity to make this control available.
Take care
Lee
-- modified at 17:07 Tuesday 21st August, 2007
|
|
|
|
|
This is a good example of a control with a rich functionality and presentable skin. What I only didn't like are the scrolling and resizing performance,
but I beleive that they would be improved by the author(community). Once more time - Great control!!! - You got my 5
|
|
|
|
|
Hi Boyko,
There are things I could do to improve scrolling and maybe resizing. Under what sort of setup did you find the performance an issue? Number of rows you had in the control, Grouping or sorting settings etc. I'd like to repro it and maybe I can fix it...
Thanks for the 5
Cheers
Lee
|
|
|
|
|
Hi Lee
Thanks for the quick reply. I've run your demo in my PC at home - its Celeron 2.93ghz with 512mb RAM. I haven't made any modifications in the demo app. What I've noticed is that the scrolling is a bit slow and the resizing of the columns could be improved. Today I've tested your code on another faster machine and I've replicated the behavior with the scrolling and resizing. Anyway the main issue I think is with the resizing performance but keep in mind that many UI vendors still experience the same issues you have.
I've still haven't gone deep in the problem but I could give you some help if it is applicable.
|
|
|
|
|
Just to be sure did you run the downloaded demo .exe or did you run it via Visual Studio in debug mode? You've probably done it already but just to rule out debug version slowness run the release version of the .exe from outside of VS.
Regards
Lee
|
|
|
|
|
Yes, I've run the demo in the release version. However, there shouldn't be a performance overhead in the both - debug and release versions maybe just the debug would be just a little bit slowlier than the release one, if the code is written correctly. Anyway thanks for the reply.
|
|
|
|
|
Hello,
I wanted to report some performanceissues,too.
I use a 24 inch display. If I maximize the application/grid and try to scroll then it is not as performant as it is in normalwindow state.
One of the problem might be the paint-events, the data is not cached but called to the accessor every time a draw occures.
I implemented additional accessors for background-/fontcolor and a string for the formated data. But even without these accessors it is still slow.
Perhaps this can be solved.
Resizing columns is slow too, so I resize the columns on mouseup-event instead in mousemove. But as I don't highlight the current size-position, the user is not informed clearly about the current operation.
I really like this control! But the performance could be better (if the grid shows a lot of columns/rows).
Regards!
|
|
|
|
|
I have two 17 inch monitors and I dragged the demo version across both of them (~2000 pixels) and it seemed fine. Could you setup the demo so that problem shows itself and send it to me...
Regards
Lee
|
|
|
|
|
Great Job on this. Can we get the Demo Source Code?
Thanks,
-Kurt
|
|
|
|
|
Hi Kurt,
The demo is with the source, it's under the Tests/SuperListTest directory.
Regards
Lee
|
|
|
|
|
I was looking for this long time ago. Well done!
|
|
|
|
|
Santiago,
Thanks for the feedback, it's always appreciated
Regards
Lee
|
|
|
|
|
5 from me.
Any chance of making it a codeplex project?
|
|
|
|
|
Hi Simon,
Thanks for the vote. Regarding a codeplex project, if you create it I'll happily upload updates when I make changes. I'm happy for people to do what they want with the Superlist source code.
Cheers
Lee
|
|
|
|
|
I am curious, why would you want him to relocate his project from one code site to another? What do you see as the benefit to Codeplex over CP? Personally, I like the way CP works, it lets me quickly cut to chase with a piece of code I see. In that, very quickly one can get a sense of how well crafted something is, find some good background info for the techniques used, and most importantly take a quick read of the member's feedback and comments. All told in about 30 seconds one can know whether or not they wish to jump down that rabbit hole so to speak...
cheers,
Keith
|
|
|
|
|
Hi Keith,
I'm guessing but perhaps he wants to contribute to the control. CP doesn't offer source control support or issue tracking which of course CodePlex does.
Regards
Lee
|
|
|
|
|
Codeproject is a wonderful site for presenting articles. It can very quickly illustrate some specific concept or piece of code.
Unfortunately it is not a very good site to host a project. There are dedicating sites for hosting projects that provide many more features that are useful for an open source project. For example Codeplex offers the following
-source control
-managed releases
-discussions
-issue/feature/request tracking
-multiple user contributions
-patch upload support for guest users
-source browsing
-project wiki
Sourceforge and Google code are other options but, since I am not familiar with them, I cannot speak to their strengths.
I guess it depend on what you are trying to achieve. If you want to publish an article with some associated source then codeproject is satisfactory. If you want to create an open source project than many people can contribute to then one of the project hosting sites is a better idea.
Kieth. Since Codeplex has wiki support the same article that is published here could be the front page of the Codeplex project.
Just my two cents
Regards
Simon
|
|
|
|
|