|
-
Jan 15th, 2004, 11:14 PM
#1
Thread Starter
Frenzied Member
listview or datagrid? [RESOLVED]
I will be getting information from a database and displaying it on a form. I am going to allow users to sort each row by clicking on each columns' header. I want grid lines (listview) but I don't know if I can do any kind of sorting with a listview control.
One other feature I'd like to incorporate is to be able to colorize individual rows depending on certain conditions.
Can anyone give me suggestions on what control to use or a combination of?
Last edited by Andy; Feb 11th, 2004 at 09:48 PM.
-
Jan 15th, 2004, 11:56 PM
#2
Member
Id go with the listview. It has sorting in Acending or Decending order. Column headers. Here is a quick code snippet on highlighting every other line of text a different color.
VB Code:
Dim item As ListViewItem
For Each item In lvwEmployeeInfo.Items
If (item.Index Mod 2) = 0 Then
item.BackColor = Color.Gray
Else
item.BackColor = Color.White
End If
Next
-
Jan 16th, 2004, 01:13 AM
#3
Frenzied Member
Binding Listview to data source is not as easy as Datagrid. And if you go for datagrid you can easily change the back color of the row depending on a condition.
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
'How will WE stand the FIRE TOMORROW?'
Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979
-
Jan 16th, 2004, 07:52 AM
#4
Thread Starter
Frenzied Member
ah, excellent arguments for both controls, fellas. I'll just have to try both. I was truly thinking that the datagrid was the way to go but I REALLY want to be able to sort by headers. Hmmm.....have to weigh my options (or write lots of code)
-
Jan 16th, 2004, 09:01 AM
#5
Member
Personally i think databinding in .net sucks. If you want ease of use and flexibility i would do it unbound. Its much more logical and your not confined to the "bound" system. Databinding manager is ridiculous.
-
Jan 17th, 2004, 02:15 AM
#6
Frenzied Member
Originally posted by AFterlife
Personally i think databinding in .net sucks. If you want ease of use and flexibility i would do it unbound. Its much more logical and your not confined to the "bound" system. Databinding manager is ridiculous.
I basically accept the idea that binding suck, but that is mainly for simple binding and would you please tell me how you gonna use datagrid if you are not going to bind it to a datasource?
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
'How will WE stand the FIRE TOMORROW?'
Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979
-
Jan 17th, 2004, 11:05 AM
#7
Member
I just meant not to do it that way. No biggie.Because i dont like to be forced to do something,in someway, that ill possibly pay for later. Which is why i stick with things that are "unbound".
-
Jan 18th, 2004, 06:09 PM
#8
Thread Starter
Frenzied Member
I'm not sure what you mean by "unbound" either. I am new to databases and the ado thing. I just discovered that the datagrid DOES have seperated lines ! How can I adjust the background color of individual records?
-
Jan 18th, 2004, 09:22 PM
#9
Frenzied Member
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
'How will WE stand the FIRE TOMORROW?'
Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979
-
Jan 18th, 2004, 09:31 PM
#10
New Member
After dropping an instance of the datagrid on the form, right-click it and choose 'Auto Format'. An auto format dialog box will appear and you can choose from predetermined layouts in the listbox on the left hand side (you will see a preview of the layout on the right hand side).
You can, thereafter if you wish, view the code generated under:
#Region " Windows Form Designer generated code "
You will see code like:
Me.DataGrid1.AlternatingBackColor = System.Drawing.Color.LightGray
Me.DataGrid1.BackColor = System.Drawing.Color.DarkGray
I personally perfer the listview if the data is read only and unbound.
In my words (a short explanation), unbound means that you must populate controls (for example from a dataview, dataset, xml file, etc.) on the form through code that you generate. As opposed to 'binding':
textbox1.DataBindings.Add("Text", dataview1, dataview1.Table.Columns(1).ColumnName)
I personally use a combination of both. The 'BindingManagerBase' object to determine where I'm at, and I populate the controls myself. But I am new to the .net architecture, so I may be making a mess of things.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|