473,395 Members | 1,473 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Listview versus DataGrid??


I am trying to decide which of these controls to use to
implement letting my user select a full row from
MyList. The MyList has several columns which would be
nice to sort by at run time. The MyList data is resident
in a dataset table.

I'm stuck and can't choose either because.

If I choose ListView as my control I don't understand how
to programmatically get the data from the dataset table
into to build or fill the ListView.

If I choose DataGrid, I understand how to get the dataset
table into the grid, but I can not find properties for
DataGrid that are like what ListView has. Specifically I
need properties like MultiSelect = False and
FullRowSelect = True to let the user select the whole
single row from MyList.
Trades analysis:

I could live with ListView and give up the nice feature
that DataGrid has for being able to sort columns at run
time.

Though, I would love to use DataGrid but without
property features like FullRowSelect=True and
MultiSelect=False I think it will be too confusing to the
user that the purpose of the DataGrid list is to
choose "a single row".
What I would need to make ListView work for me:
Example code of how to get dataset table data into to
programmatically build a ListView
What I would need to make DataGrid work for me:
Some way to simulate pseudo FullRowSelect=True and
MultiRowSelect=False properties like such as what the
ListView control has.
As a side note: I noticed that the DataGrid control for
Web Server ( I guess that means ASP.Net application) has
the ability to add buttons on each row. That would help
make it more clear to the user that they must choose a
row.

Nov 21 '05 #1
7 14935
Bob,

The most easy decission is that the listview is a readonly control (with
exception from some dump action in the first column in detail view), while
the datagrid is a read and edit control.

When you need a read only control, message than, than I can give you maybe
some more decission points.

Cor
"BobAchgill" <an*******@discussions.microsoft.com>

I am trying to decide which of these controls to use to
implement letting my user select a full row from
MyList. The MyList has several columns which would be
nice to sort by at run time. The MyList data is resident
in a dataset table.

I'm stuck and can't choose either because.

If I choose ListView as my control I don't understand how
to programmatically get the data from the dataset table
into to build or fill the ListView.

If I choose DataGrid, I understand how to get the dataset
table into the grid, but I can not find properties for
DataGrid that are like what ListView has. Specifically I
need properties like MultiSelect = False and
FullRowSelect = True to let the user select the whole
single row from MyList.
Trades analysis:

I could live with ListView and give up the nice feature
that DataGrid has for being able to sort columns at run
time.

Though, I would love to use DataGrid but without
property features like FullRowSelect=True and
MultiSelect=False I think it will be too confusing to the
user that the purpose of the DataGrid list is to
choose "a single row".
What I would need to make ListView work for me:
Example code of how to get dataset table data into to
programmatically build a ListView
What I would need to make DataGrid work for me:
Some way to simulate pseudo FullRowSelect=True and
MultiRowSelect=False properties like such as what the
ListView control has.
As a side note: I noticed that the DataGrid control for
Web Server ( I guess that means ASP.Net application) has
the ability to add buttons on each row. That would help
make it more clear to the user that they must choose a
row.

Nov 21 '05 #2
Cor,

Read only is all I need.

Bob
-----Original Message-----
Bob,

The most easy decission is that the listview is a readonly control (withexception from some dump action in the first column in detail view), whilethe datagrid is a read and edit control.

When you need a read only control, message than, than I can give you maybesome more decission points.

Cor
"BobAchgill" <an*******@discussions.microsoft.com>

I am trying to decide which of these controls to use to
implement letting my user select a full row from
MyList. The MyList has several columns which would be
nice to sort by at run time. The MyList data is resident in a dataset table.

I'm stuck and can't choose either because.

If I choose ListView as my control I don't understand how to programmatically get the data from the dataset table
into to build or fill the ListView.

If I choose DataGrid, I understand how to get the dataset table into the grid, but I can not find properties for
DataGrid that are like what ListView has. Specifically I need properties like MultiSelect = False and
FullRowSelect = True to let the user select the whole
single row from MyList.
Trades analysis:

I could live with ListView and give up the nice feature
that DataGrid has for being able to sort columns at run
time.

Though, I would love to use DataGrid but without
property features like FullRowSelect=True and
MultiSelect=False I think it will be too confusing to the user that the purpose of the DataGrid list is to
choose "a single row".
What I would need to make ListView work for me:
Example code of how to get dataset table data into to
programmatically build a ListView
What I would need to make DataGrid work for me:
Some way to simulate pseudo FullRowSelect=True and
MultiRowSelect=False properties like such as what the
ListView control has.
As a side note: I noticed that the DataGrid control for Web Server ( I guess that means ASP.Net application) has the ability to add buttons on each row. That would help make it more clear to the user that they must choose a
row.

.

Nov 21 '05 #3
Bob,
Read only is all I need.
Assuming you needs more columns, (otherwise is the listbox of course for it)
than I would probably choose when I was in your situation for the listview,
and just fill that one using a datareader in a loop. (The dataadapter does
the same, so do not be afraid of spending processingtime). In my opinion is
the listview made for what you ask. (With the information of course I have
from you now).

You can sort a listview as well and it has probably even more possibilities,
however needs some more work.

http://msdn.microsoft.com/library/de...ssorttopic.asp

Dont become afraid of the sample, most is the building of the listview,
however that you can than take as sample as well.

There also more advanced samples, as far as I remember me, do I do not like
the behaviour in this sample that it threats numbers in an alphabetic way.
However you can change that yourself.

I hope this helps?

Cor
"BobAchgill" <an*******@discussions.microsoft.com> schreef in bericht
news:08****************************@phx.gbl... Cor,

Read only is all I need.

Bob
-----Original Message-----
Bob,

The most easy decission is that the listview is a

readonly control (with
exception from some dump action in the first column in

detail view), while
the datagrid is a read and edit control.

When you need a read only control, message than, than I

can give you maybe
some more decission points.

Cor
"BobAchgill" <an*******@discussions.microsoft.com>

I am trying to decide which of these controls to use to
implement letting my user select a full row from
MyList. The MyList has several columns which would be
nice to sort by at run time. The MyList data is resident in a dataset table.

I'm stuck and can't choose either because.

If I choose ListView as my control I don't understand how to programmatically get the data from the dataset table
into to build or fill the ListView.

If I choose DataGrid, I understand how to get the dataset table into the grid, but I can not find properties for
DataGrid that are like what ListView has. Specifically I need properties like MultiSelect = False and
FullRowSelect = True to let the user select the whole
single row from MyList.
Trades analysis:

I could live with ListView and give up the nice feature
that DataGrid has for being able to sort columns at run
time.

Though, I would love to use DataGrid but without
property features like FullRowSelect=True and
MultiSelect=False I think it will be too confusing to the user that the purpose of the DataGrid list is to
choose "a single row".
What I would need to make ListView work for me:
Example code of how to get dataset table data into to
programmatically build a ListView
What I would need to make DataGrid work for me:
Some way to simulate pseudo FullRowSelect=True and
MultiRowSelect=False properties like such as what the
ListView control has.
As a side note: I noticed that the DataGrid control for Web Server ( I guess that means ASP.Net application) has the ability to add buttons on each row. That would help make it more clear to the user that they must choose a
row.

.

Nov 21 '05 #4
Cor,

The sort listview example looks great. I think I can
handle that.

But I am not sure how to implement a datareader or a
datareader to fill a listview.

As far as I understand how to do things is...

I can get my data from the access database using a
DataAdapter which gets put into my MyDataset/MyDatatable.

Does the datareader get the data the last step from the
MyDatatable to the MyListView?

Or does it take the data directly from the access
database to the MyListView?

Do you have an example of how the datareader gets the
data into the ListView? You can see why I liked
DataGrids so much... you just tell it fill and off it
goes.

Thanks!

Bob


-----Original Message-----
Bob,
Read only is all I need.
Assuming you needs more columns, (otherwise is the

listbox of course for it)than I would probably choose when I was in your situation for the listview,and just fill that one using a datareader in a loop. (The dataadapter doesthe same, so do not be afraid of spending processingtime). In my opinion isthe listview made for what you ask. (With the information of course I havefrom you now).

You can sort a listview as well and it has probably even more possibilities,however needs some more work.

http://msdn.microsoft.com/library/default.asp? url=/library/en-
us/cpref/html/frlrfsystemwindowsformslistviewclasssorttopi
c.asp
Dont become afraid of the sample, most is the building of the listview,however that you can than take as sample as well.

There also more advanced samples, as far as I remember me, do I do not likethe behaviour in this sample that it threats numbers in an alphabetic way.However you can change that yourself.

I hope this helps?

Cor
"BobAchgill" <an*******@discussions.microsoft.com> schreef in berichtnews:08****************************@phx.gbl...
Cor,

Read only is all I need.

Bob
-----Original Message-----
Bob,

The most easy decission is that the listview is a

readonly control (with
exception from some dump action in the first column in

detail view), while
the datagrid is a read and edit control.

When you need a read only control, message than, than I

can give you maybe
some more decission points.

Cor
"BobAchgill" <an*******@discussions.microsoft.com>

I am trying to decide which of these controls to use to implement letting my user select a full row from
MyList. The MyList has several columns which would be nice to sort by at run time. The MyList data is

resident
in a dataset table.

I'm stuck and can't choose either because.

If I choose ListView as my control I don't understand

how
to programmatically get the data from the dataset table into to build or fill the ListView.

If I choose DataGrid, I understand how to get the

dataset
table into the grid, but I can not find properties for DataGrid that are like what ListView has.

Specifically I
need properties like MultiSelect = False and
FullRowSelect = True to let the user select the whole
single row from MyList.
Trades analysis:

I could live with ListView and give up the nice feature that DataGrid has for being able to sort columns at run time.

Though, I would love to use DataGrid but without
property features like FullRowSelect=True and
MultiSelect=False I think it will be too confusing to

the
user that the purpose of the DataGrid list is to
choose "a single row".
What I would need to make ListView work for me:
Example code of how to get dataset table data into to programmatically build a ListView
What I would need to make DataGrid work for me:
Some way to simulate pseudo FullRowSelect=True and MultiRowSelect=False properties like such as what the
ListView control has.
As a side note: I noticed that the DataGrid control

for
Web Server ( I guess that means ASP.Net application)

has
the ability to add buttons on each row. That would

help
make it more clear to the user that they must choose a row.

.

.

Nov 21 '05 #5
Bob,

I made this little sample for you it uses the northwind database (and now
when it is ready I see you use access, however everything stays the same
when you change where used sqlclient.sql in oledb.oledb)

\\\needs a listview on a form
Private Sub Form1_Load(ByVal sender As Object, ByVal e _
As System.EventArgs) Handles MyBase.Load
Me.ListView1.View = View.Details
Me.ListView1.Columns.Add(New ColumnHeader)
Me.ListView1.Columns(0).Text = "ID"
Me.ListView1.Columns(0).Width = 20
ListView1.Columns.Add(New ColumnHeader)
ListView1.Columns(1).Text = "First Name"
Me.ListView1.Columns(1).Width = 100
Dim conn As New SqlClient.SqlConnection _
("Server=(Local); DataBase=Northwind;" & _
"Integrated Security=SSPI")
Dim rdrQuery As String = "SELECT FirstName, EmployeeID FROM
Employees"
Try
conn.Open()
Dim cmd As New SqlClient.SqlCommand(rdrQuery, conn)
Dim rdr As SqlClient.SqlDataReader = cmd.ExecuteReader()
While rdr.Read()
Dim LVI As New ListViewItem(New String() _
{rdr.GetInt32(1).ToString, rdr.GetString(0)})
'this are the items in your selectstring I setted them express with the
first needed as second
Me.ListView1.Items.Add(LVI)
End While
Catch ex As Exception
MessageBox.Show(ex.ToString)
Finally
conn.Close()
End Try
End Sub
///

I hope this helps a little bit?

Cor

"BobAchgill" <an*******@discussions.microsoft.com>
Cor,

The sort listview example looks great. I think I can
handle that.

But I am not sure how to implement a datareader or a
datareader to fill a listview.

As far as I understand how to do things is...

I can get my data from the access database using a
DataAdapter which gets put into my MyDataset/MyDatatable.

Does the datareader get the data the last step from the
MyDatatable to the MyListView?

Or does it take the data directly from the access
database to the MyListView?

Do you have an example of how the datareader gets the
data into the ListView? You can see why I liked
DataGrids so much... you just tell it fill and off it
goes.

Thanks!

Bob


-----Original Message-----
Bob,
Read only is all I need.


Assuming you needs more columns, (otherwise is the

listbox of course for it)
than I would probably choose when I was in your

situation for the listview,
and just fill that one using a datareader in a loop.

(The dataadapter does
the same, so do not be afraid of spending

processingtime). In my opinion is
the listview made for what you ask. (With the

information of course I have
from you now).

You can sort a listview as well and it has probably even

more possibilities,
however needs some more work.

http://msdn.microsoft.com/library/default.asp?

url=/library/en-
us/cpref/html/frlrfsystemwindowsformslistviewclasssorttopi
c.asp

Dont become afraid of the sample, most is the building

of the listview,
however that you can than take as sample as well.

There also more advanced samples, as far as I remember

me, do I do not like
the behaviour in this sample that it threats numbers in

an alphabetic way.
However you can change that yourself.

I hope this helps?

Cor
"BobAchgill" <an*******@discussions.microsoft.com>

schreef in bericht
news:08****************************@phx.gbl...
Cor,

Read only is all I need.

Bob
-----Original Message-----
Bob,

The most easy decission is that the listview is a
readonly control (with
exception from some dump action in the first column in
detail view), while
the datagrid is a read and edit control.

When you need a read only control, message than, than I
can give you maybe
some more decission points.

Cor
"BobAchgill" <an*******@discussions.microsoft.com>
>
> I am trying to decide which of these controls to use to> implement letting my user select a full row from
> MyList. The MyList has several columns which would be> nice to sort by at run time. The MyList data is
resident
> in a dataset table.
>
> I'm stuck and can't choose either because.
>
> If I choose ListView as my control I don't understand
how
> to programmatically get the data from the dataset table> into to build or fill the ListView.
>
> If I choose DataGrid, I understand how to get the
dataset
> table into the grid, but I can not find properties for> DataGrid that are like what ListView has.
Specifically I
> need properties like MultiSelect = False and
> FullRowSelect = True to let the user select the whole
> single row from MyList.
>
>
> Trades analysis:
>
> I could live with ListView and give up the nice feature> that DataGrid has for being able to sort columns at run> time.
>
> Though, I would love to use DataGrid but without
> property features like FullRowSelect=True and
> MultiSelect=False I think it will be too confusing to
the
> user that the purpose of the DataGrid list is to
> choose "a single row".
>
>
> What I would need to make ListView work for me:
> Example code of how to get dataset table data into to> programmatically build a ListView
>
>
> What I would need to make DataGrid work for me:
> Some way to simulate pseudo FullRowSelect=True and> MultiRowSelect=False properties like such as what the
> ListView control has.
>
>
> As a side note: I noticed that the DataGrid control
for
> Web Server ( I guess that means ASP.Net application)
has
> the ability to add buttons on each row. That would
help
> make it more clear to the user that they must choose a> row.
>
.

.

Nov 21 '05 #6
Cor,

I tried to find how to change your code to make it go to MSAccess but
could not find how.
I understand everything else you showed to me.

Bob

Nov 21 '05 #7
Bob,

Probably the connection string

\\\
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Me.ListView1.View = View.Details
Me.ListView1.Columns.Add(New ColumnHeader)
Me.ListView1.Columns(0).Text = "ID"
Me.ListView1.Columns(0).Width = 20
ListView1.Columns.Add(New ColumnHeader)
ListView1.Columns(1).Text = "First Name"
Me.ListView1.Columns(1).Width = 100
Dim conn As New OleDb.OleDbConnection _
("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Test1\Northwind.mdb;")
Dim rdrQuery As String = "SELECT FirstName, EmployeeID FROM
Employees"
Try
conn.Open()
Dim cmd As New OleDb.OleDbCommand(rdrQuery, conn)
Dim rdr As OleDb.OleDbDataReader = cmd.ExecuteReader()
While rdr.Read()
Dim LVI As New ListViewItem(New String() _
{rdr.GetInt32(1).ToString, rdr.GetString(0)})
'this are the items in your selectstring _
'I have set them express with the first needed as second
Me.ListView1.Items.Add(LVI)
End While
Catch ex As Exception
MessageBox.Show(ex.ToString)
Finally
conn.Close()
End Try
End Sub
///

I tested this one with Northwind.mdb

I hope this helps,

Cor

"BobAchgill" <Bo********@hotmail.com>
Cor,

I tried to find how to change your code to make it go to MSAccess but
could not find how.
I understand everything else you showed to me.

Bob

Nov 21 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Eva | last post by:
hi, can anyone tell me how i can retrieve specific values from a listview? i have created 6 columns that will contain values that are added on an onclick event for a button. These values are...
1
by: TusharP | last post by:
Hi Friends, How to add ListView as a row of DataGrid (Window Form DataGrid.) Please help me.... Thanking You TusharP. ---
0
by: geng | last post by:
Hello everyone ! As you can see I am new to this. It is also my first post! I have a visual c# pocket pc form with a listview in it. The listview has one column at the moment and it is populated...
2
by: Craig Petrie | last post by:
Hi, My client does not want users to change the width of a column in a ListView control. I have looked hard at properties/methods and events but can see no obvious solution. Does any one...
9
by: Martin | last post by:
On each Listview item I can add one or more so called sub-items. These subitems appear to be little more than labels. I'm curious if I could add something else as a subitem, for instance a textbox...
1
by: --== Alain ==-- | last post by:
Hi, Several months ago i've asked some information about the best way how to have some particular columns (progress bar, checkbox, images, color picker,...) in a ListView component. It seems...
5
by: --== Alain ==-- | last post by:
Hi, Several months ago i've asked some information about the best way how to have some particular columns (progress bar, checkbox, images, color picker,...) in a ListView component. It seems...
2
by: Sin Jeong-hun | last post by:
I often use detail view of the ListView control to display tabular data (is there any better way?) Many real-world applications display buttons, progress bars or dropdown lists in the columns, but...
7
by: =?Utf-8?B?YnJhaW5mdWVsbWVkaWE=?= | last post by:
Can anyone point me in the direction of creating a custom listview item? I guess the other question then - is this possible? I want to create a list of listview items comprised each comprised of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.