I'm trying to populate a List with a column of a DataTable in order to later convert it to a AutoCompleteStringCollection later. Is there a neater way to do it than the "good old" For Each?
Is there a way to use myDataTable.Rows.CopyTo for this task?
Say I have a List(Of Tag) with Tag being an object. One member of Tag, Tag.Description, is a string, and I want to make a comma-separated concatenation of the Description members.Is there an easier way to do this than to read the Description members into a List(Of String) and then use the Join function?
I have a list of strings. For each string in that list, I want to prepend another string. I wrote a method to do it, but I was wondering if there was something already in .NET I could use to do this. It seems like something that could be built in, but I was not able to find anything.
Here is the method I wrote:
Private Function PrependToAllInList(ByRef inputList As List(Of String), ByRef prependString As String) As List(Of String) Dim returnList As List(Of String) = New List(Of String) For Each inputString As String In inputList returnList.Add(String.Format("{0}{1}", prependString, inputString))
[code].....
It works, but I would rather use built in functions whenever possible.
I have read many posts on this topic; among them and most recently .NET - Convert Generic Collection to Data Table. Unfortunately, all to no avail.
I have a generic collection of structures :
Private Structure MyStruct Dim sState as String Dim lValue as Long Dim iLayer as Integer End Structure
Dim LOStates As New List(Of MyStruct) I need to fill a DataTable with this list of structures but have no idea how to go about doing this. I am using vb.net in Visual Studio 2008.
I'm making a questback in Windows forms (VB). I've succesfully setup the MySQL-database, and made connection with everything needed. I've also manage to populate a DataTable called tblAlt for the alternatives for the question.Then I try to populate each radiobutton with rows from the DataTable.Here's what I tried:
For Each row In tblAlt.Rows If tblAlt.Rows.IndexOf(row) = 0 Thenof the table).
I am trying to build a DataTable to populate a DataGrid in VB.NET. The columns will be the username and then question from an exam. Each row will be the answers by user for each question.
So it would look something like this:
Username | What is your favorite color? | What is your favorite book? ------------------------------------------------------------------------- Joe Blue The Hobbit Fred Red The Road
[Code].....
That works great and gives me a table that has the needed columns, but I am stuck as to how and get each users answer and put it under the appropriate column.
I tried adding rows in the same loop, but that just adds all of the answers under the first column.
I've got two lists, ones a DataTable, the others an array list. I want to populate a CheckBoxList with the contents of the DataTable, and check any entries that exist in the array list:
Heres the DataTable that will populate the checkboxlist with the product column:
Probably a very dumb question but I have a program whereby I create and populate an in memory datatable, which I then add to a data-set. I then run a couple of updates on the dataset and need to know how to then send these updates down into the in memory datatable :Here is a mock up of the code structure following the creation and population of the table :
There's a thread that i'd read wherein you reply regarding on shortcut on populating a listview with databatable or dataset, but i forgot it. How did you populate a listview with datatable or dataset with just one line.
In datagridview .DataSource how about in listview ?
I have a DataTable that has a hierarchyid data type column pulled from SQL Server. Is it possible to use the column to easily populate a treeview object in Visual Studio 2008?
Part 1 of what i want to do is on the Load Event of my form i want to look at an excel worksheet and populate a data table with the data found in the first two columns of the worksheet.
Essentially column 1 is Descriptions and column 2 is pricing
Part 2 of what i need to do is that when a user selects a description from the combo box it populates a text box with the appropriate pricing.
After doing some reading into this all i have seen is some threads on how to use Jet4.0 to link and grab the data but it is my understanding that Jet doesnt work with 64 bit OS.
Nonetheless I need to figure out a way to accomplish my end goal and make it as universal a solution as possible (ie. i do not want it to only run on 64 bit or 32 bit machines)
I've populated my DataTable will all the results from a SQL search. Upon a button click I want to populate a combobox with all the results where a condition is met. My DataTable as a column called UserID and I want to add all results where the UserID is equal to a set value (for example 12). I can do this to add all results and I guess I could add a if statement inside this to be If Entry.Tag = 12 Then but is there a better way?
I am trying to populat a treeview with nodes that are the values of a column in a datatable. I have managed to get the correct number of nodes but the text is not displayed next to the nodes, there is just a 3 shape but the other way round and with square corners shown.
The code is below. I would like to have these parent nodes populated on the form load and then (i think this is what i have read) to be quicker i would like to then load the childnodes once a parent node has been selected, as i don't want to load the whole database on form load or when the form is refreshed.
I want to modify this function to populate an array with each item in the database.I have tried various options, but I just can't get it to work
Private Function ConnectMe() As DataTable Dim conn As String = "Server=192.168.0.36;Port=3306;Database=wswc;Uid=r oot;Pwd=Jack" Dim cmd As String = "SELECT * FROM st_users"
[code]....
Instead of fill, I want to one by one add it to the dataset and also an array?
I'm trying to code a class of RandomNumber. One of the class methods needs to populate a "List (Of RandomNumber)" ... which was passed as a parameter to the method ... with 10 random numbers between 1 and 50. DEAD SIMPLE :)
I'm working on a project for personal use to make my life as an IT administrator a little bit easier. (Yea right)So basically, i'm creating a windows application with a form. On this form, it has a button, and a listview.When they click this button, it will load all "Windows XP run commands" into the list view. I also, have a on-click event to capture a click on certain lines in which it will automatically open said run command, or shortcut.
Here is an example of what I am working with so far. (It populates correctly, and the clicking event works like a charm. However, i'm just looking for a better way to clean this code up, or maybe, a better way to go about everything).Once done, I will populate this to the codebank if there isn't another similar thing out there.
On to the code:This is what I have for the form_load event
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load With ListView1 .View = View.Details 'Changes the view to "detailed" view .LabelEdit = True 'Allow user to edit text
I would like to write a function GetHashCodeOfList() which returns a hashcode of a list of strings regardless of order. Given 2 lists with the same strings should return the same hashcode.
ArrayList list1 = new ArrayList() list1.Add("String1"); list1.Add("String2");
[Code].....
I can first sort the list, then combine the sorted list into 1 long string and then call GetHashCode(). However sorting is a slow operation. I can get the hash of each individual string (by calling string.GetHashCode()) in the list, then multiplying all hashes and calling Mod UInt32.MaxValue. For Example: "String1".GetHashCode() * "String2".GetHashCode * ... MOD UInt32.MaxValue. But this results in a number overflow.
I don't have access to VB.NET right now so I can't test this value:Dim lst As New List(Of String)(cookieValue.Split("$"c))i got this from another question , but was wondering if A. The list will populate correctly and B. What does the c represent?
Can someone point me to a tutorial where I can learn to use the OpenFileDialog to poplulate a list box?My goal is to have a user create their own list box this way so my code can copy files to a new location without risk of damaging the original file.I am just starting to look at VB so I need some detailed instruction
I'm very new to VB.net/Vb2005. I just finished my first semester learning VB and I'm working on a few personal projects to solidify/increase what I've learned this year. Right now I'm building a simple inventory application that will keep track of individual users at my job.
The problem I'm having is in trying to populate a comboBox with items from a text file. My goal is that when the application loads, a comboBox will be populated with the names of users(located in a text file.) Upon selecting a user, the application will read some other(like users name, windows version, computer name, etc) data from another text file and populate the applications text boxes with that information.
I know how to go about building most of the application, but the problem I'm running into is how to use a text file to populate the comboBox. If I use an array or a collection for the comboBox data, then the user list will be lost each time the application closes. Also, whenver a new user is added, that data will be lost, because the collection or orray will be lost each time the application ends. Also, I don't want to use a database for the program, just a simple file.
I have two List(Of String).Both Lists contain duplicate strings. I want to pick out all the strings which are contained in both the Lists. For example:
Ok so what i'm trying to do is grab some strings from a list box and put them in an array so i can list them in a message box each index of the array on a new line
So it comes up like this
you ordered : arrayindex1 arrayindex2 arrayindex3 and so on