Hi,
I wanted to know how i can enter values into a specific
column of a listview. I have tried the following code but
this seems to enter all my values into the first column!!!
Can anyone please help me out on this??
hers my code so far.....
Private Sub btnSelRoom_Clic k(ByVal sender As
System.Object, ByVal e As System.EventArg s) Handles
btnSelRoom.Clic k
Dim ChosenDate As Date
ChosenDate = dtpRoomDate.Val ue.ToShortDateS tring
Dim ChosenRoom As SqlString
ChosenRoom = CBoxRoomNames.S electedItem
Dim ChosenLayout As SqlString
ChosenLayout = CBoxLayout.Sele ctedItem
Dim ChosenSession As SqlString
ChosenSession = CBoxSession.Sel ectedItem
Dim ChosenGuestNo As String
ChosenGuestNo = txtNoOfGuests.T ext
Dim ChosenMeal As String
Dim FullDescription As String
FullDescription = String.Format(" {0}, {1}, {2}, {3}, {4}",
ChosenDate, ChosenRoom, ChosenLayout, ChosenSession,
ChosenGuestNo)
LViewSelRooms.I tems.Add(FullDe scription)
End Sub
Many thx.
And Merry xmas to all :o) 9 6114
Hi Eva,
To add items to a listview you have to add "listviewit em"
Have a look at this page, http://msdn.microsoft.com/library/de...classtopic.asp
If you still have problems after that message again OK?
Cor I wanted to know how i can enter values into a specific column of a listview. I have tried the following code but this seems to enter all my values into the first column!!!
Can anyone please help me out on this??
hers my code so far.....
Private Sub btnSelRoom_Clic k(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles btnSelRoom.Clic k
Dim ChosenDate As Date ChosenDate = dtpRoomDate.Val ue.ToShortDateS tring Dim ChosenRoom As SqlString ChosenRoom = CBoxRoomNames.S electedItem Dim ChosenLayout As SqlString ChosenLayout = CBoxLayout.Sele ctedItem Dim ChosenSession As SqlString ChosenSession = CBoxSession.Sel ectedItem Dim ChosenGuestNo As String ChosenGuestNo = txtNoOfGuests.T ext Dim ChosenMeal As String
Dim FullDescription As String FullDescription = String.Format(" {0}, {1}, {2}, {3}, {4}", ChosenDate, ChosenRoom, ChosenLayout, ChosenSession, ChosenGuestNo)
LViewSelRooms.I tems.Add(FullDe scription)
End Sub Many thx. And Merry xmas to all :o)
Hi Cor,
thx for the link, it was very useful. im still however
having problems. im trying to insert a value obtained
from a combobox into the subitem of the listview but i
keep getting the following error....
Overload resolution failed because no accessible 'Add'
can be called with these arguments:
'Public Overloads Function Add(text As String) As
System.Windows. Forms.ListViewI tem.ListViewSub Item': Value
of type 'System.Data.Sq lTypes.SqlStrin g' cannot be
converted to 'String'.
'Public Overloads Function Add(item As
System.Windows. Forms.ListViewI tem.ListViewSub Item) As
System.Windows. Forms.ListViewI tem.ListViewSub Item': Value
of type 'System.Data.Sq lTypes.SqlStrin g' cannot be
converted
to 'System.Windows .Forms.ListView Item.ListViewSu bItem'.
I have no idea what im doin wrong!! the code i have has
been pasted below. Can u spot my Mistake??.....
Private Sub btnSelRoom_Clic k(ByVal sender As
System.Object, ByVal e As System.EventArg s) Handles
btnSelRoom.Clic k
Dim ChosenDate As Date
ChosenDate = dtpRoomDate.Val ue.ToShortDateS tring
Dim ChosenRoom As SqlString
ChosenRoom = CBoxRoomNames.S electedItem
Dim ChosenLayout As SqlString
ChosenLayout = CBoxLayout.Sele ctedItem
Dim ChosenSession As SqlString
ChosenSession = CBoxSession.Sel ectedItem
Dim ChosenGuestNo As String
ChosenGuestNo = txtNoOfGuests.T ext
Dim Item1 As New ListViewItem(Ch osenDate, 0)
Item1.SubItems. Add(ChosenRoom)
Item1.SubItems. Add("ChosenLayo ut")
LViewSelRooms.I tems.AddRange(N ew ListViewItem() {Item1})
Many thx -----Original Message----- Hi Eva,
To add items to a listview you have to add "listviewit em"
Have a look at this page,
http://msdn.microsoft.com/library/default.asp?
url=/library/en-
us/cpref/html/frlrfsystemwind owsformslistvie witemclasstopi
c.asp If you still have problems after that message again OK?
Cor
I wanted to know how i can enter values into a specific column of a listview. I have tried the following code
but this seems to enter all my values into the first
column!!! Can anyone please help me out on this??
hers my code so far.....
Private Sub btnSelRoom_Clic k(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles btnSelRoom.Clic k
Dim ChosenDate As Date ChosenDate = dtpRoomDate.Val ue.ToShortDateS tring Dim ChosenRoom As SqlString ChosenRoom = CBoxRoomNames.S electedItem Dim ChosenLayout As SqlString ChosenLayout = CBoxLayout.Sele ctedItem Dim ChosenSession As SqlString ChosenSession = CBoxSession.Sel ectedItem Dim ChosenGuestNo As String ChosenGuestNo = txtNoOfGuests.T ext Dim ChosenMeal As String
Dim FullDescription As String FullDescription = String.Format(" {0}, {1}, {2}, {3},
{4}", ChosenDate, ChosenRoom, ChosenLayout, ChosenSession, ChosenGuestNo)
LViewSelRooms.I tems.Add(FullDe scription)
End Sub Many thx. And Merry xmas to all :o)
.
Hi Eva,
It is always a gamble but I think this can it be Dim Item1 As New ListViewItem(Ch osenDate, 0) Item1.SubItems. Add(ChosenRoom) Item1.SubItems. Add("ChosenLayo ut") LViewSelRooms.I tems.AddRange(N ew ListViewItem() {Item1})
Dim Item1 As New ListViewItem(Ch osenDate, 0)
Item1.SubItems. Add(ChosenRoom)
Item1.SubItems. Add("ChosenLayo ut")
LViewSelRooms.I tems.Add(Item1)
I hope this is the sollution.
(Cannot be that big beside it if it is not).
Cor
Hi Cor,
I made the ammendment and im still getting the same
error!!
The problem seems to occur when i remove the quote marks
("") from around the item that is being added.
i.e if i add the following code...
Item1.SubItems. Add("ChosenRoom ")
it works fine but it only adds the value ChosenRoom into
my listview.
I want to add the value that is contained in this
varibale to be added in the listview so i tried...
Item1.SubItems. Add(ChosenRoom)
this however produces the error...
Overload resolution failed because no accessible 'Add'
can be called with these arguments:
'Public Overloads Function Add(text As String) As
System.Windows. Forms.ListViewI tem.ListViewSub Item': Value
of type 'System.Data.Sq lTypes.SqlStrin g' cannot be
converted to 'String'.
'Public Overloads Function Add(item As
System.Windows. Forms.ListViewI tem.ListViewSub Item) As
System.Windows. Forms.ListViewI tem.ListViewSub Item': Value
of type 'System.Data.Sq lTypes.SqlStrin g' cannot be
converted
to 'System.Windows .Forms.ListView Item.ListViewSu bItem'.
how do i actually add the value contained in the variable
into the listview?
thx -----Original Message----- Hi Eva,
It is always a gamble but I think this can it be
Dim Item1 As New ListViewItem(Ch osenDate, 0) Item1.SubItems. Add(ChosenRoom) Item1.SubItems. Add("ChosenLayo ut") LViewSelRooms.I tems.AddRange(N ew ListViewItem()
{Item1}) Dim Item1 As New ListViewItem(Ch osenDate, 0) Item1.SubItems .Add(ChosenRoom ) Item1.SubItems .Add("ChosenLay out") LViewSelRooms. Items.Add(Item1 )
I hope this is the sollution. (Cannot be that big beside it if it is not).
Cor
.
Hi,
What i just found out is that this may be a datatype
problem. It doesnt seem to like the sqlstring datatype
that i am using. I tried changing this to just STRING i.e.
.....
Dim ChosenLayout As String
ChosenLayout = CBoxLayout.Sele ctedItem
but i get a message stating...
An unhandled exception of
type 'System.Invalid CastException' occurred in
microsoft.visua lbasic.dll
Additional information: Cast from type 'SqlString' to
type 'String' is not valid.
what can i do to correct this? -----Original Message----- Hi Cor,
I made the ammendment and im still getting the same error!! The problem seems to occur when i remove the quote marks ("") from around the item that is being added.
i.e if i add the following code... Item1.SubItems .Add("ChosenRoo m") it works fine but it only adds the value ChosenRoom into my listview.
I want to add the value that is contained in this varibale to be added in the listview so i tried... Item1.SubItems .Add(ChosenRoom ) this however produces the error...
Overload resolution failed because no accessible 'Add' can be called with these arguments: 'Public Overloads Function Add(text As String) As System.Windows .Forms.ListView Item.ListViewSu bItem':
Valueof type 'System.Data.Sq lTypes.SqlStrin g' cannot be converted to 'String'. 'Public Overloads Function Add(item As System.Windows .Forms.ListView Item.ListViewSu bItem) As System.Windows .Forms.ListView Item.ListViewSu bItem':
Valueof type 'System.Data.Sq lTypes.SqlStrin g' cannot be converted to 'System.Windows .Forms.ListView Item.ListViewSu bItem'.
how do i actually add the value contained in the
variableinto the listview?
thx
-----Original Message----- Hi Eva,
It is always a gamble but I think this can it be
Dim Item1 As New ListViewItem(Ch osenDate, 0) Item1.SubItems. Add(ChosenRoom) Item1.SubItems. Add("ChosenLayo ut") LViewSelRooms.I tems.AddRange(N ew ListViewItem() {Item1}) Dim Item1 As New ListViewItem(Ch osenDate, 0) Item1.SubItem s.Add(ChosenRoo m) Item1.SubItem s.Add("ChosenLa yout") LViewSelRooms .Items.Add(Item 1)
I hope this is the sollution. (Cannot be that big beside it if it is not).
Cor
.
.
Hi Eva,
The first thing you should to put the Option Strict On in top of your
program.
(It does not help but shows you this kind of errors in develope time).
Often something simple as
a = b.tostring does than help.
But try first this.
(I do not direct understand on that place that cast error from string to
string but try this first please)
Cor
Typoes correction The first thing you should to put the Option Strict On in top of your program. (It does not help but shows you this kind of errors in develope time).
The first thing you should do, is put the Option Strict On in top of your
program.
It does not help, but it shows you this kind of errors in development time).
You might find it useful to inherit from a listViewItem
and add your object as a custom property.
eg.
Private Class MyListViewItem
Inherits Windows.Forms.L istViewItem
Private m_obj As Object
Friend Sub New(ByVal Text As String, ByVal SomeObject
as Object)
Me.m_obj = SomeObject
MyBase.New(Text )
With MyBase.SubItems
.Add(m_obj.Some Property)
.Add(m_obj.Some OtherProperty)
End With
MyBase.UseItemS tyleForSubItems = False
End Sub
Friend ReadOnly Property SomeObject() As Object
Get
Return Me.m_obj
End Get
End Property
End Class
Dim obj1 as New object
obj1.SomeProper ty = "Ben"
obj1.SomeOtherP roperty = "Reese"
'you can then add you inherited object to the list view
ListView1.Add(N ew MyListViewItem( "HI", obj1))
Dim obj2 as object
obj2 = Ctype(ListView1 .Items(0),MyLis tViewItem).Some Object
msgBox(String.F ormat("Hello {0}
{1}",obj2.SomeP roperty,obj2.So meOtherProperty ))
I have found this approach to be extremely usefull in a
number of situations.
HTH
Ben -----Original Message----- Hi Cor,
thx for the link, it was very useful. im still however having problems. im trying to insert a value obtained from a combobox into the subitem of the listview but i keep getting the following error....
Overload resolution failed because no accessible 'Add' can be called with these arguments: 'Public Overloads Function Add(text As String) As System.Windows .Forms.ListView Item.ListViewSu bItem': Value of type 'System.Data.Sq lTypes.SqlStrin g' cannot be converted to 'String'. 'Public Overloads Function Add(item As System.Windows .Forms.ListView Item.ListViewSu bItem) As System.Windows .Forms.ListView Item.ListViewSu bItem': Value of type 'System.Data.Sq lTypes.SqlStrin g' cannot be converted to 'System.Windows .Forms.ListView Item.ListViewSu bItem'.
I have no idea what im doin wrong!! the code i have has been pasted below. Can u spot my Mistake??.....
Private Sub btnSelRoom_Clic k(ByVal sender As System.Objec t, ByVal e As System.EventArg s) Handles btnSelRoom.Cli ck Dim ChosenDate As Date ChosenDate = dtpRoomDate.Val ue.ToShortDateS tring Dim ChosenRoom As SqlString ChosenRoom = CBoxRoomNames.S electedItem Dim ChosenLayout As SqlString ChosenLayout = CBoxLayout.Sele ctedItem Dim ChosenSession As SqlString ChosenSession = CBoxSession.Sel ectedItem Dim ChosenGuestNo As String ChosenGuestNo = txtNoOfGuests.T ext
Dim Item1 As New ListViewItem(Ch osenDate, 0) Item1.SubItems. Add(ChosenRoom) Item1.SubItems. Add("ChosenLayo ut")
LViewSelRooms.I tems.AddRange(N ew ListViewItem() {Item1})
Many thx
-----Original Message----- Hi Eva,
To add items to a listview you have to add "listviewit em"
Have a look at this page,
http://msdn.microsoft.com/library/default.asp? url=/library/en- us/cpref/html/frlrfsystemwind owsformslistvie witemclasstopi c.asp If you still have problems after that message again OK?
Cor
I wanted to know how i can enter values into a specific column of a listview. I have tried the following codebut this seems to enter all my values into the firstcolumn!!! Can anyone please help me out on this??
hers my code so far.....
Private Sub btnSelRoom_Clic k(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles btnSelRoom.Clic k
Dim ChosenDate As Date ChosenDate = dtpRoomDate.Val ue.ToShortDateS tring Dim ChosenRoom As SqlString ChosenRoom = CBoxRoomNames.S electedItem Dim ChosenLayout As SqlString ChosenLayout = CBoxLayout.Sele ctedItem Dim ChosenSession As SqlString ChosenSession = CBoxSession.Sel ectedItem Dim ChosenGuestNo As String ChosenGuestNo = txtNoOfGuests.T ext Dim ChosenMeal As String
Dim FullDescription As String FullDescription = String.Format(" {0}, {1}, {2}, {3},{4}", ChosenDate, ChosenRoom, ChosenLayout, ChosenSession, ChosenGuestNo)
LViewSelRooms.I tems.Add(FullDe scription)
End Sub Many thx. And Merry xmas to all :o)
.
.
you do have a data type problem
Lisview items and sub items take strings as parameters not
sqlString.
Consider using the ToString method on the SqlString
Dim s as New System.Data.SQL Types.SQLString ("SELECT * FROM
Products")
Listview.Items. Add("Hi")
ListView.Items( 0).SubItems.Add (s.ToString)
Alternatively see my earlier post which has accidently
gone in higher up the tree on inheriting from the
listviewitem.
Ben -----Original Message----- Typoes correction The first thing you should to put the Option Strict On
in top of your program. (It does not help but shows you this kind of errors in
develope time).The first thing you should do, is put the Option Strict
On in top of yourprogram.
It does not help, but it shows you this kind of errors in
development time).
. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: cybertof |
last post by:
Hello,
Is there a solution to the following problem :
When filling a listview (30 columns) with around 5000 items, it can take
easily 10 sec for the listview to be filled.
I have used BeginUpdate and SuspendLayout but no speed...
Here is a flavor of the code :
|
by: Andrew |
last post by:
If item is a ListViewItem and str is a string, why do the following two lines
not have the same effect ?
item.SubItems.Add(new ListViewItem.ListViewSubItem()).Text =
str;
item.SubItems.Add(str);
In the example code that follows, using the first line (in the ListView
constructor) causes the later redisplay of values (to some specified number
of decimal places) in the ListView not to work. Using the second line causes
|
by: Holmes |
last post by:
Hello
Ran into a bit of a problem here and have now exhausted my resources to getting this working
What I am trying to do is load and show a simple vb form with a listbox in it
Dim frm_nc_code As New frm_nc_sen
frm_nc_code.Show(
Well what I want to have happen is it loads the form then shows all of the controls on the form (especially the listview control which should be blank at this time)
|
by: Ash Phillips |
last post by:
Hi Everyone,
I have this program I wrote in VB6 for family use. It's a DVD Database just
for me to keep track of them cause I have so many lol.
In VB6, I could add items to the ListView in 'frmMain' from 'frmAdd' with
the following code:
Private Function AddEntry(Title As String, Rating As String, Genre As
String, OnLoan As Boolean, ToWho As String)
|
by: dotnetnewbie |
last post by:
Whilst looping through items in a listview I wish to have the option of
inserting a new row (in the middle not necessarily at the end of the
listview).
thus if lvw is the listview name
dim itm as listviewitem
For each itm in lvw.Items
'if certain condition is met then insert new row in the listview here
| |
by: Eva |
last post by:
Hi,
I wanted to know how i can enter values into a specific
column of a listview. I have tried the following code but
this seems to enter all my values into the first column!!!
Can anyone please help me out on this??
hers my code so far.....
|
by: sonu |
last post by:
Hi all,
I have a listview control which has four columns like { Col1, Col2,
Col3, Col4}.
I add data in listview like this,
dim lvitem as listviewItem
|
by: Alexander Overmann |
last post by:
Hello,
currently we encounter several huge memoryproblems running .NET C#
Applications under Windows Terminal Servers/Citrix. Sometimes the program
claims 100 MB which is not very much at a single PC but a pain in the ass at
a Terminalserver when 20-25 Users start the program (25*100 = 2500 MB).
We made some analysis:
|
by: Kadett |
last post by:
Hi all, I have following problem: I'm creating a ListView (Details) control
at run-time and filling it with some records (let's say 10 000). This
operation seems to be quite fast, but when I call Controls.Add(list),
where list is my ListView control, then program hangs for minute. It seems
like this time depends on number of records added to control. So probably
when adding control to my form, those records are actualy added at this time...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |