Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Data Binding / November 2005

Tip: Looking for answers? Try searching our database.

databinding 2 datagridview

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bruno Alexandre - 15 Nov 2005 12:54 GMT
Hi guys,

   I have 2 questions regarding this issue:

   1st. Why this code gives me the lenght of the string instead the string
itself?

Dim a As New ArrayList
a.Add(DirectCast(LProb_DataPassivos.Value.ToShortDateString, String))
a.Add(DirectCast(LProb_DescricaoPassivos.Text, String))
dgListaProblemasPassivos.DataSource = a

   2nd. Why VS gives me an error when doing this, saying that I have to use
the NEW key:

user.arrayList_pass.Add(DirectCast(LProb_DataPassivos.Value.ToShortDateString,
String))
user.arrayList_pass.Add(DirectCast(LProb_DescricaoPassivos.Text, String))
dgPass.DataSource = user.arrayList_pass

   I can't use the NEW because user.arrayList_pass is a ArrayList property
from my Class and it ould reach this point with data on the ArrayList, so I
can't have a new one, I will loose every previous data.

Signature

Bruno Alexandre
(Sintra, PORTUGAL)

Bart Mermuys - 15 Nov 2005 14:02 GMT
Hi,

> Hi guys,
>
[quoted text clipped - 7 lines]
> a.Add(DirectCast(LProb_DescricaoPassivos.Text, String))
> dgListaProblemasPassivos.DataSource = a

Because a DataGridView can have multiple columns and when you bind an object
then the names of the properties are used for the column headers and the
values for the cells in a row.  A string is an object with one property
Length.

If you only have one column, you could consider using a simple ListBox,
otherwise you will need to either create your own class with a single
property that returns a string or use a DataTable with a single Column.

If you're using .NET2.0 it's also better to use a generic BindingList<Of T>
instead of ArrayList.

Can't help you with the second problem.

HTH,
Greetings

>    2nd. Why VS gives me an error when doing this, saying that I have to
> use the NEW key:
[quoted text clipped - 7 lines]
> from my Class and it ould reach this point with data on the ArrayList, so
> I can't have a new one, I will loose every previous data.
Bruno Alexandre - 15 Nov 2005 14:37 GMT
I change it to DataTable instead ArrayList

:-)

Signature

Bruno Alexandre
(Sintra, PORTUGAL)

> Hi guys,
>
[quoted text clipped - 19 lines]
> from my Class and it ould reach this point with data on the ArrayList, so
> I can't have a new one, I will loose every previous data.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.