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 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.
>
.
.