|
That looks like that did the trick!
I don't need to reference dummy somewhere?
Virtual Space Shuttle Astronaut
|
|
|
|
|
The Mighty Atom wrote: I don't need to reference dummy somewhere?
No, there isn't much you could do with it anyway. If you get a compiler warning, you might even get away with the simpler statement:
ListView1.Handle
which obtains the handle and forgets it right away.
|
|
|
|
|
Tried ListView1.Handle instead of Dim Dummy As IntPtr = ListView1.Handle but that produces an error:
Property access must assign to the property or use its value.
So i guess its Dim Dummy As IntPtr = ListView1.Handle after all, eh?
Virtual Space Shuttle Astronaut
modified on Monday, October 4, 2010 12:49 PM
|
|
|
|
|
Hey guys I am having trouble trying to remove and option from a ListBox. I can set settings easy but having a hard time trying to remove the selected item within the listbox.
Public Class Form1
'Load Settings
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For Each item As String In My.Settings.lbCollection
lbView.Items.Add(item)
Next
End Sub
'Save settings when form closes
Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
My.Settings.Save()
End Sub
'Add settings when btn_Add" is clicked to listbox and settings
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If tbAddCollection.Text <> "" And lbView.Items.Contains(tbAddCollection.Text) = False Then
lbView.Items.Add(tbAddCollection.Text)
My.Settings.lbCollection.Add(tbAddCollection.Text)
End If
End Sub
'Display selected item in Textbox
Private Sub lbView_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lbView.SelectedIndexChanged
tbAddCollection.Text = lbView.SelectedItem
End Sub
'Remove selected item and its setting
Private Sub btnRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemove.Click
If lbView.SelectedIndex <> -1 Then
lbView.Items.RemoveAt(lbView.SelectedIndex)
My.Settings.lbCollection.(lbView.SelectedItem)
End If
End Sub
End Class
Im completely lost =(
|
|
|
|
|
Herboren wrote: having a hard time trying to remove the selected item within the listbox.
You could start by explaining what you expect to happen and what does happen.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Well I understand that lbCollect(my listbox) is storing my settings in an array. While removing an entry from the list box I would also like to remove the entry from My.Settings or at least change its value to nothing or clear it so when I load my program again, it wont load that value into my list box. But I am not sure if that will screw things up, seeing how my settings were added to a string collection, parts of the string array would be empty.
Kindly as I stated in my previous statement, I would like to remove the selected list box item from My.Settings as well.
|
|
|
|
|
Your code snippet is incomplete. This line won't even compile (at the bottom or your code snippet) and there's no way to tell what you had in there:
My.Settings.lbCollection.(lbView.SelectedItem)
You also provide no explanation of what you expect to happen and what really does happen when you run this code.
|
|
|
|
|
Well I understand it was incomplete. I am aware of that, but if you had read the block or my comment above it, you would know what my goal was.
|
|
|
|
|
Herboren wrote: if you had read the block or my comment above it
comments aren't very trustworthy while debugging code that malfunctions. Comments may be wrong. Compilers don't read comments, and you admitted being "completely lost", so the actual code would have been the best starting point (unless it's too long of course).
|
|
|
|
|
and that is why I posted code, besides I was at a mcdonalds hotspot typing in my car, thats difficult, but dont worry, I dont code and drive at the same time
|
|
|
|
|
Herboren wrote: I was at a mcdonalds hotspot typing in my car
Just leaving work were you
[Its a joke, those in the know might get it!!!!!]
Dave
Find Me On: Web| Facebook| Twitter| LinkedIn
CPRepWatcher now available as Packaged Chrome Extension, visit my articles for link.
|
|
|
|
|
actually i work in IT but we got rid of the bright broadband to save money, me and the wife live off hotspots =)
|
|
|
|
|
Look at the code below. This works fine.
In the Settings, the listbox items to be stored should be saved in type Specialized String Collection;
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
updateList()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If ListBox1.SelectedIndices.Count > 0 Then
ListBox1.Items.RemoveAt(ListBox1.SelectedIndices(0))
End If
Dim newlist As New Specialized.StringCollection
For Each item In ListBox1.Items
newlist.Add(item)
Next
My.Settings.Item("theList") = newlist
My.Settings.Save()
updateList()
End Sub
Private Sub updateList()
ListBox1.Items.Clear()
For Each item As String In My.Settings.Item("theList")
ListBox1.Items.Add(item)
Next
End Sub
Dave
Find Me On: Web| Facebook| Twitter| LinkedIn
CPRepWatcher now available as Packaged Chrome Extension, visit my articles for link.
|
|
|
|
|
I understand how the settings are saved, but to actually remove the setting from the string collection is what im trying to accomplish
|
|
|
|
|
It shows you in the button click event, recreate a specialized string collection and push it back onto my settings.
Dave
Find Me On: Web| Facebook| Twitter| LinkedIn
CPRepWatcher now available as Packaged Chrome Extension, visit my articles for link.
|
|
|
|
|
Public Sub DatePersian(ByRef StrDay As String, ByRef StrMonth As String, ByRef StrDayOfMonth As String, ByRef StrYear As String)
Dim P As New Globalization.PersianCalendar
Select Case P.GetDayOfWeek(Date.UtcNow)
Case DayOfWeek.Friday : StrDay = "جمعه"
Case DayOfWeek.Monday : StrDay = "دوشنبه"
Case DayOfWeek.Saturday : StrDay = "شنبه"
Case DayOfWeek.Sunday : StrDay = "یکشنبه"
Case DayOfWeek.Thursday : StrDay = "پنج شنبه"
Case DayOfWeek.Tuesday : StrDay = "سه شنبه"
Case DayOfWeek.Wednesday : StrDay = "چهارشنبه"
End Select
Select Case P.GetMonth(Date.UtcNow)
Case 1 : StrMonth = "فروردین"
Case 2 : StrMonth = "اردیبهشت"
Case 3 : StrMonth = "خرداد"
Case 4 : StrMonth = "تیر"
Case 5 : StrMonth = "مرداد"
Case 6 : StrMonth = "شهریور"
Case 7 : StrMonth = "مهر"
Case 8 : StrMonth = "آبان"
Case 9 : StrMonth = "آذر"
Case 10 : StrMonth = "دی"
Case 11 : StrMonth = "بهمن"
Case 12 : StrMonth = "اسفند"
End Select
StrDayOfMonth = P.GetDayOfMonth(Date.UtcNow).ToString
StrYear = P.GetYear(Date.UtcNow).ToString()
End Sub
|
|
|
|
|
As you forgot to ask a question, I'll ask you some:
- why are you using DateTime.UtcNow several times? are you aware they may all return a different value, and if you're unlucky, the net result will be very incorrect?
- why are you using select constructs for translating a number into a string? wouldn't initialized arrays be the obvious choice?
- why didn't you post your code snippet in PRE tags? and add some text explaining what is going on?
I noticed you are new on CodeProject so all is forgiven. However, I strongly suggest you:
1. read the "how to ask a question" and "how to get an answer" messages on top of this forum;
2. read some other posts, to see how other people are handling things.
Cheers.
|
|
|
|
|
Hi,
I am writing a vb.net application. I have a listview with 4 columns. I want to put these values into an array. What is the best way of doing this.
|
|
|
|
|
IMO a ListView is a viewer, which means it shows data it got somewhere; that same somewhere should be used to stuff an array, not the ListView itself. You shouldn't mix up presentation and business layers.
|
|
|
|
|
I have ceated two application, each having a UDP socket.One applicaion broadcast data in network using udp socket and other application search for the same in the network and if it finds the data it respond.
Now problem is when I use applications on different machines then it works fine.But when I use both application on the same machine then one application never search the broadcasted data.
How can I make changes like "loopBack" so that when both application run on the same machine, it works fine...
Thanks in adv....
|
|
|
|
|
Thanks in advance..!
I am working on a POS system in that I have to use Kitchen Printer which is connected to a Monitor /Output Device
what i need to know is how to display Orders on Kitchen Printer (Output Device) , Is it same like printing on a printer or what any Helping material/Link would be highly appreciated
SOFTDEV
Luck in life always exists in the form of an abstract class that cannot be instantiated directly and needs to be inherited by hard work and dedication.
|
|
|
|
|
Your best source of information is the printers documentation.
Chances are, you'll be printing raw data directly to the printer. How you do that depends entirely on the devices you are working with and what they support.
|
|
|
|
|
Thanks , searching for Devices any one you wants to recommend
SOFTDEV
Luck in life always exists in the form of an abstract class that cannot be instantiated directly and needs to be inherited by hard work and dedication.
|
|
|
|
|
Nope. I've never used any of them.
|
|
|
|
|
Thanks
SOFTDEV
Luck in life always exists in the form of an abstract class that cannot be instantiated directly and needs to be inherited by hard work and dedication.
|
|
|
|