|
Hello,
>It will be wonderful if you can give me some pointers on this
Well it should be pretty simple to get it working with a DataTable, since it has columns and rows of course In my demo example I use a Person object as a row which I then make use of in the columnItemValueAccessor delegate. What you might want to do to save duplicating data is just pass in the DataTable's DataRow and use that for pulling the cell values out.
I guess the only slight issue you might have is deciding how wide the columns should be, currently there is no way in the Superlist of saying "Make columns the width of their data content". This is something I want to rectify at some point.
Finally if you have so many rows that you find the application getting a bit jerky (Superlist sorts on idle) you might want to set ListControl.Items.ProcessingStyle = BinaryComponents.SuperList.ItemLists.ProcessingStyle.Thread . This makes Superlist do its sorting in a background thread. Note you have to be careful as any column properties maybe called by a separate thread then.
Regards
Lee
|
|
|
|
|
Cool one, you've got my five.
One question: why using hand-made GDI wrapperes instead of these in the System.Drawing.Graphics object?
Greetings - Gajatko
|
|
|
|
|
Hi,
The reason is that GDI+ drawing of text utilizes grid fitting which can cause the text to look slightly spaced out on occasions and for the text to dance around whilst for example your sizing columns etc...Also when measuring text you don't necessarily get the right size back of strings, there tends to be a slight overhang. Still if you want to use GDI+ exclusively its easy to code the GDI+ versions.
Cheers
Lee
|
|
|
|
|
Hi,
great control, which seems also pretty fast (at least for my purpose). But how about localize it to make it more useable in other languages ?
|
|
|
|
|
Yep it's one of the things including designer support that I should get around to at some point. If only there enough hours in the day
Regards
Lee
|
|
|
|
|
I've been playing with this all morning, 5 from me.
"It was the day before today.... I remember it like it was yesterday."
-Moleman
|
|
|
|
|
Thanks I'm glad you like it!!!
Regards
Lee
|
|
|
|
|
it will be helpfull if u upload code for demo..
gr8 job ...
|
|
|
|
|
Hi,
The demo is with the source, it's under the Tests/SuperListTest directory.
Regards
Lee
|
|
|
|
|
Excellent control.
How I can use the control in vb2005 and using like source given a database?
-- modified at 3:20 Thursday 23rd August, 2007
|
|
|
|
|
I've never actually tried to use it with VB as I'm exclusively a C# developer however if your using Visual Studio you it should work simply by adding the project reference to your VB project. If your using the Express edition then I think you will have to build the DLL first and then add the DLL reference as Visual Studio Express doesn't support multi-language solutions from what I remember.
Regards
Lee
|
|
|
|
|
just add reference of dll or this source project in your vb project
and use it like
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)
_superList.Columns.Add(surnameColumn)
_superList.Columns.Add(firstnameColumn)
_superList.Columns.Add(phoneColumn)
_superList.Columns.Add(stateColumn)
_superList.Columns.Add(cityColumn)
need to create method for
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
|
|
|
|
|
The code that you have posted works perfectly.
Thank you
|
|
|
|
|
Hi
I'm using vb.net 2005 and I want to use this control with a datatable.
How can I add Items to this control with a datatble?
I'll appreciate a sample of code
Thanks and Regards,
Eli
|
|
|
|
|
'---This sample use TableAdapter and a BindingSource of db table.
Private Structure Person
Dim surname As String
Dim firstname As String
Dim phone As String
Dim city As String
Dim state As String
Dim datetime As Date
End Structure
Dim Tab_PersonBindingSource as BindingSource
Private Sub Load()
Me.Tab_PersonTableAdapter.Fill(me.PersonDataSet.Tab_Person)
LoadColumns()
GetData()
End Sub
Private Sub LoadColumns()
Me.ListControl1.Columns.Clear()
Dim surnameColumn As New Column("surname", "Surname", 150, AddressOf surname)
Dim firstnameColumn As New Column("firstname", "First Name", 150, AddressOf firstname)
Dim phoneColumn As New Column("phone", "Phone", 220, AddressOf phone)
Dim cityColumn As New Column("city", "City", 80, AddressOf city)
Dim stateColumn As New Column("state", "State", 70, AddressOf state)
Dim dateColumn As New Column("data", "Date", 100, AddressOf Data)
Me.ListControl1.Columns.Add(surnameColumn)
Me.ListControl1.Columns.Add(firstnameColumn)
Me.ListControl1.Columns.Add(dateColumn)
Me.ListControl1.Columns.Add(phoneColumn)
Me.ListControl1.Columns.Add(cityColumn)
Me.ListControl1.Columns.Add(stateColumn)
dateColumn.GroupItemAccessor = New ColumnItemValueAccessor(AddressOf GroupValueFromItem)
dateColumn.MoveBehaviour = Column.MoveToGroupBehaviour.Copy
dateColumn.GroupSortOrder = SortOrder.Descending
surnameColumn.SortOrder = SortOrder.Ascending
End sub
Private Sub GetData()
Me.PersonBindingSource.MoveFirst()
Me.ListControl1.Items.Clear()
For Each cf As DataRowView In Me.PersonBindingSource
Dim np As New Person
np.surname = cf.Item(0)
np.firstname = cf.Item(1)
np.phone = cf.Item(2)
np.city = cf.item(4)
np.state = cf.Item(5)
np.datetime = cf.Item(6)
Me.ListControl1.Items.Add(np)
Next
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 Function Data(ByVal obj As Object) As Object
Return DirectCast(obj, Person).DateTime
End Function
Private Function GroupValueFromItem(ByVal o As Object) As Object
Dim DateTime As Date = CType(o.datetime, Date)
Dim publicationDate As Date = DateTime
Dim weekStart As Date = Now.AddDays(-Now.DayOfWeek)
Dim monthStart As Date = Now.AddDays(-Now.Day)
Dim days As Double = Now.Subtract(publicationDate).TotalDays
If (days < 1) Then
Return "Today"
ElseIf (days < 2) Then
Return "Yesterday"
ElseIf (publicationDate > weekStart) Then
Return "This Week"
ElseIf (publicationDate > weekStart.AddDays(-7)) Then
Return "Last Week"
ElseIf (publicationDate > monthStart) Then
Return "This Month"
ElseIf (publicationDate > monthStart.AddMonths(-1).AddDays(1)) Then
Return "Last Month"
Else
Return "Older"
End If
End Function
-- modified at 10:25 Friday 24th August, 2007
|
|
|
|
|
Hi,
Thanks for your prompt response.
Unfortunaltely, I have some problems with the superlist on vb.2005,
I got 2 problems:
1. The list is empty
2. I got an unhandled error: {"Failed to compare two elements in the array."}
I did almost exactly what you did.
I reference the BinaryComponents.SuperList.dll and filled the list.
While debugging, I checked for the _superlist.Items.Count and it appears to be 0 length also after : Me._superlist.Items.Add(oShows)
Your help will be appreciated
Thanks
Eli
|
|
|
|
|
Hello Eli,
The reason the count is zero is because the items only get *added* after they've been processed. But I'd say that its failed at the processing stage as the things you have added aren't comparable as they don't implement IComparable . You need to either get the items to implement IComparable or otherwise override the Column.Comparitor and Column.GroupedComparitor properties instead.
HTH
Regards
Lee
|
|
|
|
|
Sorry I'm having trouble getting my head around this, if I copy'n'paste your code in every function ie,
<br />
Private Function surname(ByVal obj As Object) As Object<br />
Return DirectCast(obj, Person).Surname<br />
End Function<br />
I get "Type 'Person' is not defined" errors.
Can someone give me an example of how to overcome this problem?
Any help greatly appreciated.
Rob
|
|
|
|
|
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?
|
|
|
|
|