473,943 Members | 2,276 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Databind DataGridView to List(of String)

I use the following code to programmaticall y bind a DataGridView and a
BindingNavigato r to various List(of myClass). This works fine with each
'myClass' offering public properties.

Dim mAllUsers As List(Of myClass)
mAllUsers = GetAllUsers() 'returns List(Of myClass)
Dim AllUsersBinding Source As New BindingSource(M e.components)
ControlStationI nfoBindingNavig ator.BindingSou rce = AllUsersBinding Source
ControlStationI nfoDataGridView .AutoGenerateCo lumns = True
ControlStationI nfoDataGridView .DataSource = AllUsersBinding Source
AllUsersBinding Source.DataSour ce = mAllUsers

If I change the code to
Dim mAllUsers As List(Of String)
mAllUsers = GetAllUsers() 'returns List(Of String)
then the DataGridView only displays one column containing the length of each
string.

I want only to display the strings in one column.

thank you very much, herbert

Jun 27 '08 #1
1 6664
You could try using a BindingList(of whatever) instead of a List. It has all
the inherent properties needed to bind a list to a binding list and thus to
a control.

RobinS.
GoldMail.com

"herbert" <he*****@discus sions.microsoft .comwrote in message
news:5A******** *************** ***********@mic rosoft.com...
>I use the following code to programmaticall y bind a DataGridView and a
BindingNavigato r to various List(of myClass). This works fine with each
'myClass' offering public properties.

Dim mAllUsers As List(Of myClass)
mAllUsers = GetAllUsers() 'returns List(Of myClass)
Dim AllUsersBinding Source As New BindingSource(M e.components)
ControlStationI nfoBindingNavig ator.BindingSou rce = AllUsersBinding Source
ControlStationI nfoDataGridView .AutoGenerateCo lumns = True
ControlStationI nfoDataGridView .DataSource = AllUsersBinding Source
AllUsersBinding Source.DataSour ce = mAllUsers

If I change the code to
Dim mAllUsers As List(Of String)
mAllUsers = GetAllUsers() 'returns List(Of String)
then the DataGridView only displays one column containing the length of
each
string.

I want only to display the strings in one column.

thank you very much, herbert
Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
2981
by: Klaus Neuner | last post by:
Hello, I need a function that converts a list into a set of regexes. Like so: string_list = print string_list2regexes(string_list) This should return something like:
4
9128
by: blrmaani | last post by:
Here is what I want: string s1 = "This is a list of string"; list<string> s2 = s1.some_method(); Now, I should be able to traverse list s2 and get each member ( which is of type 'string' ). I know that this can be achieved using strtok. But I was wondering
9
4460
by: incredible | last post by:
how to sort link list of string
10
26841
by: Jeff Williams | last post by:
How can I get a list of the Groups both Local and Domain groups a User belongs to.
6
2352
by: Bryan | last post by:
I am writing a class that has a list of strings as one of its properties. I want to be able to run some code whenever that list of strings is modified through the class property. Here is the definition of the property 'JobSites' Public Class SiteList Private _JobSites As New List(Of String) Public Property JobSites() As List(Of String) Get Return _JobSites
9
2808
by: shapper | last post by:
Hello, How can I filter a List(Of String)? I need to get the list elements which start with the letters contained in the variable Text. Thanks, Miguel
8
12227
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
I'm trying to get a list of SQL Server Instances thru a VB.NET application. I have tried GetDataSource and SMO. I have also tried using ListSQLSvr.exe from http://www.sqldev.net/misc/ListSQLSvr.htm I run all of them on a Windows XP Professional 64bit machine which has 2 instances: mymachine\SQLExpress (Express Edition) and MSSQLSERVER (Developer Edition (64bit)) SQL Browser Service: not running
7
4731
by: Karch | last post by:
I need to find the fastest way in terms of storage and searching to determine if a given string contains one of a member of a list of strings. So, think of it in terms of this: I have a string such as the following: "Smith said the dog belongs (or did belong) to the secretary, an employee of the company." Then the list contains the following (and this list is MUCH larger in the real situation):
1
1390
by: Matt Lowrance | last post by:
I have created an object that has a number of properties, that I am now trying to simply databind to a form. I am using the data designer to do it and just dragging and dropping the items onto the form. Everything works great, except one of the items in my object is a list of dates. Right now I am using a generic list to hold these, but when I go to put this item on the form it only lists "None" as the type of control I can use to...
0
10135
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9970
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,...
0
11534
Oralloy
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...
1
11299
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,...
1
8219
isladogs
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...
0
7390
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6087
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...
0
6308
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4910
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.