473,385 Members | 1,325 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Databind DataGridView to List(of String)

I use the following code to programmatically bind a DataGridView and a
BindingNavigator 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 AllUsersBindingSource As New BindingSource(Me.components)
ControlStationInfoBindingNavigator.BindingSource = AllUsersBindingSource
ControlStationInfoDataGridView.AutoGenerateColumns = True
ControlStationInfoDataGridView.DataSource = AllUsersBindingSource
AllUsersBindingSource.DataSource = 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 6561
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*****@discussions.microsoft.comwrote in message
news:5A**********************************@microsof t.com...
>I use the following code to programmatically bind a DataGridView and a
BindingNavigator 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 AllUsersBindingSource As New BindingSource(Me.components)
ControlStationInfoBindingNavigator.BindingSource = AllUsersBindingSource
ControlStationInfoDataGridView.AutoGenerateColumns = True
ControlStationInfoDataGridView.DataSource = AllUsersBindingSource
AllUsersBindingSource.DataSource = 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
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
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' ). ...
9
by: incredible | last post by:
how to sort link list of string
10
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
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...
9
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
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...
7
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...
1
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.