Answered by:
listitem not defined

Question
-
hi all,
I have a problem I have a list box and have added an item into this
ListBox1.Items.Add(
New ListItem(result.Properties("displayName")(i).ToString, result.Properties("sAMAccountname")(i).ToString))
but it says Listitem is not defined i went through some forums and found out that You have reference to assembly with System.Web.dll and import System.Web.UI.WebControls namespace
i have done that but as soon as i have done that it gives me some other problem
Is there a way around this
Dim Tnode As TreeNode = TreeView1.Nodes.Add("(Drive Q:)")
cannot convert system.windows.forms.tree to system.web.ui.webcontrols.treenode
Wednesday, September 15, 2010 10:54 AM
Answers
-
On Wed, 15 Sep 2010 13:27:52 +0200, <roma_victa> wrote:> yes but it solves one error but as soon as i Imports> System.Web.UI.WebControls>> there is lots of errors even the views and taken as web controls>> is there any way that we can get the same functionality as listItem in> Windows> applicationIf you want to add a Item to the Items of the Listbox, which in fact is aSystem.Windows.Forms.ListBox.ObjectCollection you can do it like this:ListBox1.Items.Add(result.Properties("displayName")(i).ToString & "," &result.Properties("sAMAccountname")(i).ToString)This will add the String "TheDisplayname,TheSamAccountname".Just skip the ListItem stuff and add a concated string like in the exampleabove.
Hannes
If you have got questions about this, just ask.
Mark the thread as answered if the answer helps you. This helps others who have the same problem !
C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/- Proposed as answer by Blackwood Wednesday, September 15, 2010 1:59 PM
- Marked as answer by roma_victa Sunday, September 19, 2010 10:51 AM
Wednesday, September 15, 2010 11:38 AM
All replies
-
Hi,
how about:
Dim Tnode As System.Windows.Forms.TreeNode= TreeView1.Nodes.Add("(Drive Q:)")
Hannes
If you have got questions about this, just ask.
Mark the thread as answered if the answer helps you. This helps others who have the same problem !
C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/Wednesday, September 15, 2010 11:08 AM -
yes but it solves one error but as soon as i Imports System.Web.UI.WebControls
there is lots of errors even the views and taken as web controls
is there any way that we can get the same functionality as listItem in Windows application
Wednesday, September 15, 2010 11:27 AM -
On Wed, 15 Sep 2010 13:27:52 +0200, <roma_victa> wrote:> yes but it solves one error but as soon as i Imports> System.Web.UI.WebControls>> there is lots of errors even the views and taken as web controls>> is there any way that we can get the same functionality as listItem in> Windows> applicationIf you want to add a Item to the Items of the Listbox, which in fact is aSystem.Windows.Forms.ListBox.ObjectCollection you can do it like this:ListBox1.Items.Add(result.Properties("displayName")(i).ToString & "," &result.Properties("sAMAccountname")(i).ToString)This will add the String "TheDisplayname,TheSamAccountname".Just skip the ListItem stuff and add a concated string like in the exampleabove.
Hannes
If you have got questions about this, just ask.
Mark the thread as answered if the answer helps you. This helps others who have the same problem !
C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/- Proposed as answer by Blackwood Wednesday, September 15, 2010 1:59 PM
- Marked as answer by roma_victa Sunday, September 19, 2010 10:51 AM
Wednesday, September 15, 2010 11:38 AM -
Is there any way that i can make this as key value pair??Thursday, September 16, 2010 3:33 AM
-
Hi,
you can do this just like in the sample below:
'Visual Basic 2008 - .net 3.5 - Any CPU Dim MyDisplaySamAccountList As New List(Of KeyValuePair(Of String, String)) MyDisplaySamAccountList.Add(New KeyValuePair(Of String, String)("SamAccountName One", "DisplayName One")) MyDisplaySamAccountList.Add(New KeyValuePair(Of String, String)("SamAccountName Two", "DisplayName Two")) ListBox1.DataSource = MyDisplaySamAccountList ListBox1.ValueMember = "Key" ListBox1.DisplayMember = "Value"
Hannes
If you have got questions about this, just ask.
Mark the thread as answered if the answer helps you. This helps others who have the same problem !
C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/Thursday, September 16, 2010 5:49 AM