473,509 Members | 10,100 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataSource at design time

IN VB.NET
I have a form with a ListBox and would like to set the DataSource property
at design-time but I can't seem to declare any kind of variable that will
show up in the list. I have tried a traditional array, ArrayList,
Collection as public vars in the Form Class's Declarations section. Setting
the DataSource property to any of these works fine at run time.

I want to do it at design time because after I change the Collection, it
doesn't update it in the ListBox, even though breaking showed that the
Collection.Count property had gone up. I first add to it in code with
Coll.Add("WHATEVER") and it shows up fine, before and after binding. But I
try
to do this: Coll.Add(TextBox1.Text) and it doesn't show up in the ListBox
but is apparently being added to the collection object just fine.

Any answer to either of these questions would be helpful
Thanks,
Stephen
Nov 20 '05 #1
4 6952
Stephen,
At design time the only 'native' collection that I know of you can use is a
DataTable (specifically a DataTable in a DataSet.)

You can then add new rows to the DataTable's Rows collection and they will
show up in the List.

The reason adding items to the ArrayList do not show up in the ListBox is
that the ArrayList does not support the ListChanged event (part of the
IBindingList interface).

Is there a reason you want to bind to a DataSource as opposed to simply
adding the items to the ListBox.Items collection (via the ListBox.Items.Add
method)?

Hope this helps
Jay

"Stephen" <gr******@bellatlantic.net> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
IN VB.NET
I have a form with a ListBox and would like to set the DataSource property
at design-time but I can't seem to declare any kind of variable that will
show up in the list. I have tried a traditional array, ArrayList,
Collection as public vars in the Form Class's Declarations section. Setting the DataSource property to any of these works fine at run time.

I want to do it at design time because after I change the Collection, it
doesn't update it in the ListBox, even though breaking showed that the
Collection.Count property had gone up. I first add to it in code with
Coll.Add("WHATEVER") and it shows up fine, before and after binding. But I try
to do this: Coll.Add(TextBox1.Text) and it doesn't show up in the ListBox
but is apparently being added to the collection object just fine.

Any answer to either of these questions would be helpful
Thanks,
Stephen

Nov 20 '05 #2
Simplicity, speed and the guarantee that the data is exactly the same. .NET
is supposed to make for rapid app development after all. Is there a way to
refresh the ListBox? I tried rebinding it after the data changed but it
didn't work. Maybe I have to unbind it then rebind it.

"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message
news:ON*************@tk2msftngp13.phx.gbl...
Stephen,
At design time the only 'native' collection that I know of you can use is a DataTable (specifically a DataTable in a DataSet.)

You can then add new rows to the DataTable's Rows collection and they will
show up in the List.

The reason adding items to the ArrayList do not show up in the ListBox is
that the ArrayList does not support the ListChanged event (part of the
IBindingList interface).

Is there a reason you want to bind to a DataSource as opposed to simply
adding the items to the ListBox.Items collection (via the ListBox.Items.Add method)?

Hope this helps
Jay

"Stephen" <gr******@bellatlantic.net> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
IN VB.NET
I have a form with a ListBox and would like to set the DataSource property at design-time but I can't seem to declare any kind of variable that will show up in the list. I have tried a traditional array, ArrayList,
Collection as public vars in the Form Class's Declarations section. Setting
the DataSource property to any of these works fine at run time.

I want to do it at design time because after I change the Collection, it
doesn't update it in the ListBox, even though breaking showed that the
Collection.Count property had gone up. I first add to it in code with
Coll.Add("WHATEVER") and it shows up fine, before and after binding. But I
try
to do this: Coll.Add(TextBox1.Text) and it doesn't show up in the

ListBox but is apparently being added to the collection object just fine.

Any answer to either of these questions would be helpful
Thanks,
Stephen


Nov 20 '05 #3
Hi Stephen,

Since the refresh of ListBox doesn't work when items are added or removed
from the arraylist, the simplest workaround is to reset the DataSource
property of the ListBox. you can try the following code to achieve this.

arraylist.Add("Whatever")
listbox.DataSource = Nothing
listbox.DataSource = arraylist

You cannot omit the second line, because if you simply set the
listbox.DataSource to arraylist, the listbox will check if the new
DataSource is the same as the old one. (The listbox doesn't know that the
arraylist has changed, it only knows that they are the same object
reference.)

Does this answer your question? If anything is unclear, please feel free to
reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

--------------------
| From: "Stephen" <gr******@bellatlantic.net>
| References: <#k*************@TK2MSFTNGP11.phx.gbl>
<ON*************@tk2msftngp13.phx.gbl>
| Subject: Re: DataSource at design time
| Date: Thu, 2 Oct 2003 23:37:35 -0400
| Lines: 59
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <eP**************@TK2MSFTNGP10.phx.gbl>
| Newsgroups: microsoft.public.dotnet.languages.vb
| NNTP-Posting-Host: c-66-177-177-97.se.client2.attbi.com 66.177.177.97
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:143316
| X-Tomcat-NG: microsoft.public.dotnet.languages.vb
|
| Simplicity, speed and the guarantee that the data is exactly the same.
..NET
| is supposed to make for rapid app development after all. Is there a way
to
| refresh the ListBox? I tried rebinding it after the data changed but it
| didn't work. Maybe I have to unbind it then rebind it.
|
| "Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in
message
| news:ON*************@tk2msftngp13.phx.gbl...
| > Stephen,
| > At design time the only 'native' collection that I know of you can use
is
| a
| > DataTable (specifically a DataTable in a DataSet.)
| >
| > You can then add new rows to the DataTable's Rows collection and they
will
| > show up in the List.
| >
| > The reason adding items to the ArrayList do not show up in the ListBox
is
| > that the ArrayList does not support the ListChanged event (part of the
| > IBindingList interface).
| >
| > Is there a reason you want to bind to a DataSource as opposed to simply
| > adding the items to the ListBox.Items collection (via the
| ListBox.Items.Add
| > method)?
| >
| > Hope this helps
| > Jay
| >
| > "Stephen" <gr******@bellatlantic.net> wrote in message
| > news:%2***************@TK2MSFTNGP11.phx.gbl...
| > > IN VB.NET
| > > I have a form with a ListBox and would like to set the DataSource
| property
| > > at design-time but I can't seem to declare any kind of variable that
| will
| > > show up in the list. I have tried a traditional array, ArrayList,
| > > Collection as public vars in the Form Class's Declarations section.
| > Setting
| > > the DataSource property to any of these works fine at run time.
| > >
| > > I want to do it at design time because after I change the Collection,
it
| > > doesn't update it in the ListBox, even though breaking showed that the
| > > Collection.Count property had gone up. I first add to it in code with
| > > Coll.Add("WHATEVER") and it shows up fine, before and after binding.
| But
| > I
| > > try
| > > to do this: Coll.Add(TextBox1.Text) and it doesn't show up in the
| ListBox
| > > but is apparently being added to the collection object just fine.
| > >
| > > Any answer to either of these questions would be helpful
| > > Thanks,
| > > Stephen
| > >
| > >
| >
| >
|
|
|

Nov 20 '05 #4
Stephen,
Simplicity, speed and the guarantee that the data is exactly the same. ..NET is supposed to make for rapid app development after all. Huh? Based on the above it sounds like you want to use ListBox.Items. It is
simply, it is speedy. I'm not sure what you are comparing to be exactly the
same.
Is there a way to refresh the ListBox? Yes binding to a class that implements IBindingList such as DataTable
(DataView) will refresh the ListBox automatically.

Also using the ListBox.Items collection instead of an ArrayList will cause
the ListBox to be refreshed.

I have not tried Kevin's code I would expect Kevin's code to also refresh
the ListBox, for the reason's Kevin identified.

Hope this helps
Jay

"Stephen" <gr******@bellatlantic.net> wrote in message
news:eP****************@TK2MSFTNGP10.phx.gbl... Simplicity, speed and the guarantee that the data is exactly the same. ..NET is supposed to make for rapid app development after all. Is there a way to refresh the ListBox? I tried rebinding it after the data changed but it
didn't work. Maybe I have to unbind it then rebind it.

"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message news:ON*************@tk2msftngp13.phx.gbl...
Stephen,
At design time the only 'native' collection that I know of you can use is
a
DataTable (specifically a DataTable in a DataSet.)

You can then add new rows to the DataTable's Rows collection and they will show up in the List.

The reason adding items to the ArrayList do not show up in the ListBox is that the ArrayList does not support the ListChanged event (part of the
IBindingList interface).

Is there a reason you want to bind to a DataSource as opposed to simply
adding the items to the ListBox.Items collection (via the

ListBox.Items.Add
method)?

Hope this helps
Jay

"Stephen" <gr******@bellatlantic.net> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
IN VB.NET
I have a form with a ListBox and would like to set the DataSource

property at design-time but I can't seem to declare any kind of variable that will show up in the list. I have tried a traditional array, ArrayList,
Collection as public vars in the Form Class's Declarations section.

Setting
the DataSource property to any of these works fine at run time.

I want to do it at design time because after I change the Collection, it doesn't update it in the ListBox, even though breaking showed that the
Collection.Count property had gone up. I first add to it in code with
Coll.Add("WHATEVER") and it shows up fine, before and after binding. But
I
try
to do this: Coll.Add(TextBox1.Text) and it doesn't show up in the

ListBox but is apparently being added to the collection object just fine.

Any answer to either of these questions would be helpful
Thanks,
Stephen



Nov 20 '05 #5

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

Similar topics

0
1633
by: Slonjo | last post by:
I don't know if this has been addressed in some other form/forum but we tried what we thought was everything. I apologize if i'm being redundant. We build reports like so when they require...
2
4847
by: Angel | last post by:
The Winform datagrid I'm working is already displaying data from a datatable. How can I add columns to that datagrid? I know (or at least I think I know) how to add the tableStyle and...
3
16804
by: lee_mcknight | last post by:
I am using Crystal Enterprise V9. I have a report that needs to have multiple datasets as the datasource(s) on a single subreport (some common lookup data I need to join to is stored in a seperate...
3
11000
by: Alvaro E. Gonzalez V. | last post by:
Hello!!! I'm building a control that in a property assign a Dataset which they are initialized and another property Like DataMember. Similar as it happens to the DataSource property of a...
4
6176
by: dyw55a | last post by:
Donna Mar 15, 10:11 am show options Newsgroups: microsoft.public.dotnet.framework.adonet From: "Donna" <dyw...@yahoo.com> - Find messages by this author Date: 15 Mar 2005 10:11:56 -0800...
0
2060
by: Martin Widmer | last post by:
Hello again! I have a datagridview control on my form and am using VS.Net 2005. One column is set up as combo box column, and when I try to set the datasource for that combobox column at design...
0
1133
by: bill | last post by:
The design time Connection string for my table adapters don't change/can't be set during run time. I have a business layer class project and added a typed dataset. In VS2005 the Table adapter...
0
899
by: Annie | last post by:
hello guys, I am using Object Datasource in my GUI and binding the GRID's data source to Object Datasource and everything is working ok. Pageing and sorting is working fine too ... However,...
5
2663
by: forest demon | last post by:
what i'm trying to do is attach a report file to a reportviewer instance with some values from a page. i can attach a dataset to the .rdlc file with stuff from a datasource, but i need to also add...
0
7137
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...
0
7347
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,...
0
7416
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7073
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...
0
7506
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5656
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5062
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...
0
4732
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...
0
3207
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.