473,386 Members | 1,798 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,386 software developers and data experts.

design time databinding

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("XXX") 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
1 2551
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>
| Subject: design time databinding
| Date: Thu, 2 Oct 2003 22:07:17 -0400
| Lines: 18
| 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: <eb**************@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!TK2MSFTNGXA06.phx.gbl!TK2MSFT NGXA05.phx.gbl!TK2MSFTNGP0
8.phx.gbl!TK2MSFTNGP10.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:143300
| X-Tomcat-NG: microsoft.public.dotnet.languages.vb
|
| 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("XXX") 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

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

Similar topics

1
by: PCC | last post by:
I am writing a data access layer for a web service. Data from the web service is to be returned as XML. My design dilemma is this... Should I be returning XML from my stored procedures using...
2
by: muesliflakes | last post by:
I have a DataSet that bound to controls on multiple forms. Currently an instance is created on each form and Load / Write is handled on each form. Instead I would like to have a single instance...
1
by: Martin | last post by:
Hi, I've got a web label control which I set a databind expression on the Text attribute in the html for the page (aspx file). At runtime, I want to override this attribute, so before I do...
6
by: M | last post by:
I binding controls to a dataset at design time. I find the checkboxs will cause the program crash when one of these databinding fields is dbnull. The only way for me is not set databindings for...
10
by: Matthew Hood | last post by:
My company is just starting development of a new project using VB.NET. The question I have is, since the release of VS 2005 and the 2.0 Framework comming out soon, should we start developing with...
11
by: Peter M. | last post by:
Hi all, I'm currently designing an n-tier application and have some doubts about my design. I have created a Data Access layer which connects to the database (SQL Server) and performs Select,...
2
by: Kalpesh | last post by:
Hello, I am facing a design problem here & need your expert design advice on this. Scenario: I have a class called Vendor - which has several simple attributes like Name, Address etc Now,...
0
by: Kalpesh | last post by:
Hello, I am facing a design problem here & need your expert design advice on this. Scenario: I have a class called Vendor - which has several simple attributes like Name, Address etc Now,...
1
by: Mark Olbert | last post by:
Has anyone else noticed that the design-time support for databinding in custom controls in ASPNET2 sucks? At least for GridViews? So far I've spent going on two days trying to get the following...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...

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.