473,575 Members | 3,366 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 programmaticall y 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=T rue and
MultiSelect=Fal se 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
programmaticall y build a ListView
What I would need to make DataGrid work for me:
Some way to simulate pseudo FullRowSelect=T rue 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 14968
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*******@disc ussions.microso ft.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 programmaticall y 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=T rue and
MultiSelect=Fal se 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
programmaticall y build a ListView
What I would need to make DataGrid work for me:
Some way to simulate pseudo FullRowSelect=T rue 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*******@disc ussions.microso ft.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 programmaticall y 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=T rue and
MultiSelect=Fal se 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
programmaticall y build a ListView
What I would need to make DataGrid work for me:
Some way to simulate pseudo FullRowSelect=T rue 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*******@disc ussions.microso ft.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*******@disc ussions.microso ft.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 programmaticall y 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=T rue and
MultiSelect=Fal se 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
programmaticall y build a ListView
What I would need to make DataGrid work for me:
Some way to simulate pseudo FullRowSelect=T rue 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/frlrfsystemwind owsformslistvie wclasssorttopi
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*******@disc ussions.microso ft.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
"BobAchgil l" <an*******@disc ussions.microso ft.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 programmaticall y 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=T rue and
MultiSelect=Fal se 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 programmaticall y build a ListView
What I would need to make DataGrid work for me:
Some way to simulate pseudo FullRowSelect=T rue 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(ByVa l sender As Object, ByVal e _
As System.EventArg s) Handles MyBase.Load
Me.ListView1.Vi ew = View.Details
Me.ListView1.Co lumns.Add(New ColumnHeader)
Me.ListView1.Co lumns(0).Text = "ID"
Me.ListView1.Co lumns(0).Width = 20
ListView1.Colum ns.Add(New ColumnHeader)
ListView1.Colum ns(1).Text = "First Name"
Me.ListView1.Co lumns(1).Width = 100
Dim conn As New SqlClient.SqlCo nnection _
("Server=(Local ); DataBase=Northw ind;" & _
"Integrated Security=SSPI")
Dim rdrQuery As String = "SELECT FirstName, EmployeeID FROM
Employees"
Try
conn.Open()
Dim cmd As New SqlClient.SqlCo mmand(rdrQuery, conn)
Dim rdr As SqlClient.SqlDa taReader = cmd.ExecuteRead er()
While rdr.Read()
Dim LVI As New ListViewItem(Ne w 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.It ems.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*******@disc ussions.microso ft.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/frlrfsystemwind owsformslistvie wclasssorttopi
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*******@disc ussions.microso ft.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*******@disc ussions.microso ft.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 programmaticall y 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=T rue and
> MultiSelect=Fal se 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> programmaticall y build a ListView
>
>
> What I would need to make DataGrid work for me:
> Some way to simulate pseudo FullRowSelect=T rue 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(ByVa l sender As Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
Me.ListView1.Vi ew = View.Details
Me.ListView1.Co lumns.Add(New ColumnHeader)
Me.ListView1.Co lumns(0).Text = "ID"
Me.ListView1.Co lumns(0).Width = 20
ListView1.Colum ns.Add(New ColumnHeader)
ListView1.Colum ns(1).Text = "First Name"
Me.ListView1.Co lumns(1).Width = 100
Dim conn As New OleDb.OleDbConn ection _
("Provider=Micr osoft.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.OleDbComm and(rdrQuery, conn)
Dim rdr As OleDb.OleDbData Reader = cmd.ExecuteRead er()
While rdr.Read()
Dim LVI As New ListViewItem(Ne w 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.It ems.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********@hot mail.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
2585
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 ontained from the user via textboxes, comboboxes etc.
1
1591
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
2976
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 by using a textbox and a button. I am trying to save to contents of the listview to an Xml file. I have the following code and the debugger gives...
2
7474
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 have a tip on how to handle this in vb.Net(2003) Thanks
9
2424
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 or combobox. Would anyone know if that's possible and if so, how to do it? Tia, Martin
1
1579
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 that ListView is a complex component and a lot of people advise to build a custom component but not from ListVIew itself. Some use a datagrid...
5
1795
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 that ListView is a complex component and a lot of people advise to build a custom component but not from ListVIew itself. Some use a datagrid...
2
1866
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 it seems like ListView only allows texts. I guess if I can only know the exact bounds of the columns, I could overlay other Windows controls on it...
7
5100
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 text and a set of textboxes.
0
8120
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8281
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7868
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6515
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5664
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5338
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3778
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3797
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1382
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.