|
Hi,
I am trying to insert selected items from a listbox into a label, the listbox is fillby a database query, the problem is all I get is this System.Data.DataRowView it works fine when I dont use a database query and just text in the listbox, but need to use a database query.
Can anyone help on a solution for this??
Dim i As Integer<br />
For i = 0 To ListBoxUpgrade.Items.Count - 1<br />
If ListBoxUpgrade.Items(i) Then<br />
LabelSum.Text = LabelSum.Text & Space(6) & ListBoxUpgrade.SelectedItem(i) & vbCrLf<br />
End If<br />
Next i
Thanks in advance!
Stefan.
"All answers have a question? All code has an end."
|
|
|
|
|
smguc wrote: ListBoxUpgrade.SelectedItem(i)
try ListBoxUpgrade.SelectedItem(i).Text instead
without .Text the ToString() method gets called, which by default returns a string
naming the type.
|
|
|
|
|
Hi Luc,
Thanks for that, but doesn't accept the .text after the ListBoxUpgrade.SelectedItem(i) so frustrading it works in 'VB6' which is where I have upgraded from to 'VB2005' all because of 'Vista', many different rules and changes.
What I am trying to achieve, is there is a list of items in a listbox which you can multi select and from there show only those selected items in a label as a summary 'like a report'.
Any more suggestions would be much appreciated!
Thanks,
Stefan.
"All answers have a question? All code has an end."
|
|
|
|
|
I missed that you missed an 's'
try ListBoxUpgrade.SelectedItems(i).Text instead
|
|
|
|
|
Hmmm...
No still no luck! Doesn't like the .text after it.
Sometimes makes me think I should go back to VB6, haha. Was like my second lanugage!
This is the code for VB6, which works fine the only difference is that the 'i' was declare as a variant, but VB2005 wants it as a object, which didn't work so changed it to a Integer.
<br />
Dim i As Variant<br />
For i = 0 To ListBoxUpgrade.ListCount - 1<br />
If ListBoxUpgrade.Selected(i) Then<br />
LabelSum = LabelSum & Space(6) & ListBoxUpgrade.List(i, 3) & vbCrLf<br />
End If<br />
Next i
Do you have any more ideas or a better way to write the code??
Or go back to VB6... lol
Thanks,
Stefan.
"All answers have a question? All code has an end."
|
|
|
|
|
Dont go back to VB6, if anything show your current VB.NET code here.
And tell exactly what the current result is and what it should be.
|
|
|
|
|
The listbox contains objects which could be anything. ListBoxUpgrade.SelectedItem(i) will return whatever text the ToString method returns. For most objects this is the type of object it is. Because you've bound your listview you actually have a listview full of DataRowView objects. This is why the ToString method is returning System.Data.DataRowView. If you want to get the corresponding text of the item (the text being displayed in the listbox) you can use the GetItemText method.
For Each obj As Object In ListBox1.SelectedItems
Console.WriteLine(ListBox1.GetItemText(obj))
Next
|
|
|
|
|
Hi, that looks great. Never knew VB code could look so clean.
|
|
|
|
|
Excellent!
Thank you very much!
You would not believe the amount of books I have, and read that doesn't even state the 'GetItemText' method, Have only just made the transistion in VB2005 a few weeks now.
Great help!
Thanks again.
Stefan.
"All answers have a question? All code has an end."
|
|
|
|
|
That's what IntelliSense is for Also the MSDN library is a big help.
|
|
|
|
|
Hi all!
I'm sure there’s a commonly well known way to do this, but after days of googling and googling I can't seem to find a procedure.
I have an application the works with a SQL database, I want it to work with the data in a specific field, and then return that value to the database.
Where I'm stuck is that I can't figure out how to set a variable = to the data in a specific field.
Can someone please outline what I need to do, or point me to a specific tutorial?
Thanks for any help!
--Derek
|
|
|
|
|
instead of googling for days, spend a couple of hours reading some of the
excellent articles here on CodeProject (I am not saying they are all
excellent, but there are some bloody good ones !). There is a search facility
at the top of most pages on CodeProject.
|
|
|
|
|
I think you forgot something ...
finally { appropriateForum.Post(message); }
I'm largely language agnostic
After a while they all bug me
|
|
|
|
|
no no, finally block gets executed no matter what, and that is not required once
you found a solution somewhere.
Furthermore it would exceed the allowed 500 char maximum for a sig.
|
|
|
|
|
I realised the second I posted it. Shame, in english it sounds good. C# not so much.
I'm largely language agnostic
After a while they all bug me
|
|
|
|
|
Well, strickly speaking it shouldn't be finally but I had a geek attack. End of the day.
I'm largely language agnostic
After a while they all bug me
|
|
|
|
|
I appericate your reply, but I don't ask questions on formums unless I've done my research
|
|
|
|
|
Hi,
I did not intend to offend you, but so many questions seem to be asked because
asking looks simpler than searching...
I am not a database programmer (nor fluent in VB), this is a pattern (in C#) that
I encountered in many articles and discussions (I do read a lot of them):
for a DataSet ds the j-th field in row i can be accessed (read/written) by
ds.Tables["tableName"].Rows[i].ItemArray[j]
I am confident you know how to translate it to VB syntax.
I have never used it, but I do hope this helps. If not, maybe you should
post a new question, this time in the SQL/ADO.NET forum ...
|
|
|
|
|
Sorry, I didn't mean to be a jerk either, thanks for your help!
|
|
|
|
|
Hi,
I am new to this. I need some help with password recovery control. How do we use this?
I tried for some example but did not fine anything. Can some one give a small example how to send password through email?
Shirhit
|
|
|
|
|
Which bit are you stuck on ? The .NET framework has classes that make it easy to send email, and you would typically reset the password and send that, but you could get the existing one, if you needed to.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
There is an In-built class password recovery in asp.net2.0 version.
Are you using that one oe you have created your own?
Let all of us know where you have got the Problem so that only we can help you.
Regards,
Satips.
Don't walk in front of me, I may not follow;
Don't walk behind me, I may not lead;
Walk beside me, and just be my friend. - Albert Camus
|
|
|
|
|
I am using the built in Password recovery in asp.net. 1. Do I have to give the database connection in the page load or in the submit button?
2. How do you send an email to the user with new reset password?
|
|
|
|
|
I used the drag-a-data-source-to-the-screen method to build a data form.
When I click the X on the navigator toolstrip, it prompts me as in the following code,
but then it deletes the record anyway even if I choose No.
Debugging shows it never does the RemoveCurrent line when I choose No.
Can someone tell me what is happening? Is there an unseen method being called?
I can't find an e.Cancel to use like in other methods.
Private Sub BindingNavigatorDeleteItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorDeleteItem.Click
Me.Validate()
If MessageBox.Show("Are you sure you want to delete this employee?", _
"Employee", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.Yes Then
EmployeeBindingSource.RemoveCurrent()
End If
End Sub
Paul Watson wrote:
Like, if you say sort of, like, you know, one more, you know, time, I'm going to, like, you know, sort of sort you out, you know.
|
|
|
|
|
This might work if it has a handled function:
If MessageBox.Show("Are you sure you want to delete this employee?", _
"Employee", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.Yes Then
EmployeeBindingSource.RemoveCurrent()
else
e.handled = true
End If
Posted by The ANZAC : "WWBD, What Would Buffy Do?" : "I don't know man, she's stronger than me"
|
|
|
|