473,774 Members | 2,176 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.Coun t property had gone up. I first add to it in code with
Coll.Add("WHATE VER") and it shows up fine, before and after binding. But I
try
to do this: Coll.Add(TextBo x1.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 6972
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.A dd
method)?

Hope this helps
Jay

"Stephen" <gr******@bella tlantic.net> wrote in message
news:%2******** *******@TK2MSFT NGP11.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.Coun t property had gone up. I first add to it in code with
Coll.Add("WHATE VER") and it shows up fine, before and after binding. But I try
to do this: Coll.Add(TextBo x1.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********@ema il.msn.com> wrote in message
news:ON******** *****@tk2msftng p13.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.A dd method)?

Hope this helps
Jay

"Stephen" <gr******@bella tlantic.net> wrote in message
news:%2******** *******@TK2MSFT NGP11.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.Coun t property had gone up. I first add to it in code with
Coll.Add("WHATE VER") and it shows up fine, before and after binding. But I
try
to do this: Coll.Add(TextBo x1.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.DataSou rce = Nothing
listbox.DataSou rce = arraylist

You cannot omit the second line, because if you simply set the
listbox.DataSou rce 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******@bella tlantic.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.publi c.dotnet.langua ges.vb
| NNTP-Posting-Host: c-66-177-177-97.se.client2.a ttbi.com 66.177.177.97
| Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP10.phx.g bl
| Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.vb:143316
| X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.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********@ema il.msn.com> wrote in
message
| news:ON******** *****@tk2msftng p13.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.A dd
| > method)?
| >
| > Hope this helps
| > Jay
| >
| > "Stephen" <gr******@bella tlantic.net> wrote in message
| > news:%2******** *******@TK2MSFT NGP11.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.Coun t property had gone up. I first add to it in code with
| > > Coll.Add("WHATE VER") and it shows up fine, before and after binding.
| But
| > I
| > > try
| > > to do this: Coll.Add(TextBo x1.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******@bella tlantic.net> wrote in message
news:eP******** ********@TK2MSF TNGP10.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********@ema il.msn.com> wrote in message news:ON******** *****@tk2msftng p13.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.A dd
method)?

Hope this helps
Jay

"Stephen" <gr******@bella tlantic.net> wrote in message
news:%2******** *******@TK2MSFT NGP11.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.Coun t property had gone up. I first add to it in code with
Coll.Add("WHATE VER") and it shows up fine, before and after binding. But
I
try
to do this: Coll.Add(TextBo x1.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
1651
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 passing parameters to limit the results: One person develops the report layout using a view. The other person creates a datatable at runtime from a stored proc
2
4861
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 gridColumnStyles during design time but I don't know what to do next (make the grid display the data). The datatable is filled during run-time. Thanks, Angel
3
16831
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 dataset). The report is working fine with a single dataset as a datasource, but I cannot seem to find any examples of multiple datasets as a datasource. Is this possible? ReportDocument.SetDatasource() seems to only take a single dataset,...
3
11017
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 System.Windows.Forms.ListBox... That mechanism can be used or as is the best way to do it...
4
6200
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 Local: Tues, Mar 15 2005 10:11 am Subject: VB.NET dynamically create datagrid and set its datasource Reply | Reply to Author | Forward | Print | Individual Message | Show original | Report Abuse
0
2088
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 time in the properties section of VS, I get the error "object reference not set to instance of an object" and the only option is to click OK. I have not yet tried to set that datasource at runtime, but of course I could do that. But I don't...
0
1155
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 comes with it. Great! But the Datasource/ConnectionString is automagically set to the DB from which I did the drag and drop. I want to use this TA in a UI. The UI has the same My.Settings connectionstring setting in it, but with a different...
0
909
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, what I want is to set the Grid source to object data source by code (not design time) which still works fine however the paging and sorting raises error ... i do as below:
5
2676
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 values form a pages web controls to the same report. it was recommended, on here, that i create a dataset in memory and add that to the report. i'm not sure how to do that at this point without a datasource. i'm drawing a blank. thanks to...
0
9621
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
10106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9914
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7463
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
6717
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
5355
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
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4012
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
3
2852
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.