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

Fill a listbox with app.config data

WB
I'm just starting out with C# after many years with VB 6.0.

I'm trying to fill a listbox with a list of computer names (almost 100) from
app.config. First, is app.config the place to store and retrieve this large
list?

If so, I'm looking for code to obtain the list of computer names from
app.config, and also an example of how the computer names need to be listed
in app.config.

Thanks,
--
Bill Baker
Aug 7 '06 #1
4 2872
Hi WB,

I'm would probably have stored the list in a (comma)separate(d) file instead of App.config.
To read the file you could use

string data File.ReadAll(filename);
string[] names = data.Split(',');
On Mon, 07 Aug 2006 20:05:58 +0200, WB <WB@discussions.microsoft.comwrote:
I'm just starting out with C# after many years with VB 6.0.

I'm trying to fill a listbox with a list of computer names (almost 100) from
app.config. First, is app.config the place to store and retrieve this large
list?

If so, I'm looking for code to obtain the list of computer names from
app.config, and also an example of how the computer names need to be listed
in app.config.

Thanks,


--
Happy coding!
Morten Wennevik [C# MVP]
Aug 7 '06 #2
I should correct myself

string[] names = File.ReadAllLines(filename);
On Mon, 07 Aug 2006 20:47:02 +0200, Morten Wennevik <Mo************@hotmail.comwrote:
Hi WB,

I'm would probably have stored the list in a (comma)separate(d) file instead of App.config.
To read the file you could use

string data File.ReadAll(filename);
string[] names = data.Split(',');
On Mon, 07 Aug 2006 20:05:58 +0200, WB <WB@discussions.microsoft.comwrote:
>I'm just starting out with C# after many years with VB 6.0.

I'm trying to fill a listbox with a list of computer names (almost 100) from
app.config. First, is app.config the place to store and retrieve thislarge
list?

If so, I'm looking for code to obtain the list of computer names from
app.config, and also an example of how the computer names need to be listed
in app.config.

Thanks,




--
Happy coding!
Morten Wennevik [C# MVP]
Aug 7 '06 #3

Bill,

I would not store this list in app/settings. Especially the comma delimited
route.

There are a couple of options that I have done:

I usually put a list, which only changes every blue moon its its own little
xml file.
Since you're new to dotNet, do a search for "Strong typed DataSet".
This will allow you to call methods like .WriteXml and LoadXml( string
fileName ).
What I'm saying is that you can store it in a small xml file , and if you
piggy back off your custom strongly typed dataset, you can use those easy to
use methods, especially the LoadXml one.

Secondly, you can write you own "Custom Configuration Handler", and add some
xml to the existing app.config (or web.config) file.
<mystuff>
<state name="Virginia" abbv="VA" />
<state name="North Carolina" abbv="NC" />
<state name="Tennesee" abbv="TN" />
</mystuff>

but it takes some coding/work to get this working. However, learning how to
write a custom config handler is a very good base skill.

go and google this
http://www.google.com/search?hl=en&l...ration+section
http://support.microsoft.com/kb/309045/EN-US/

There are multiple options, somebody will post another probably. But those
2 have served me well.

But littering up the app/settings is kinda hacky in my book.


"WB" <WB@discussions.microsoft.comwrote in message
news:F5**********************************@microsof t.com...
I'm just starting out with C# after many years with VB 6.0.

I'm trying to fill a listbox with a list of computer names (almost 100)
from
app.config. First, is app.config the place to store and retrieve this
large
list?

If so, I'm looking for code to obtain the list of computer names from
app.config, and also an example of how the computer names need to be
listed
in app.config.

Thanks,
--
Bill Baker

Aug 7 '06 #4
Ya, I don't think you should store you data in app.config too. As the name
implied it is for your application configuration. You really should think of
XML or database and worst come to worst a text file.

chanmm

"sloan" <sl***@ipass.netwrote in message
news:uX**************@TK2MSFTNGP03.phx.gbl...
>
Bill,

I would not store this list in app/settings. Especially the comma
delimited
route.

There are a couple of options that I have done:

I usually put a list, which only changes every blue moon its its own
little
xml file.
Since you're new to dotNet, do a search for "Strong typed DataSet".
This will allow you to call methods like .WriteXml and LoadXml( string
fileName ).
What I'm saying is that you can store it in a small xml file , and if you
piggy back off your custom strongly typed dataset, you can use those easy
to
use methods, especially the LoadXml one.

Secondly, you can write you own "Custom Configuration Handler", and add
some
xml to the existing app.config (or web.config) file.
<mystuff>
<state name="Virginia" abbv="VA" />
<state name="North Carolina" abbv="NC" />
<state name="Tennesee" abbv="TN" />
</mystuff>

but it takes some coding/work to get this working. However, learning how
to
write a custom config handler is a very good base skill.

go and google this
http://www.google.com/search?hl=en&l...ration+section
http://support.microsoft.com/kb/309045/EN-US/

There are multiple options, somebody will post another probably. But
those
2 have served me well.

But littering up the app/settings is kinda hacky in my book.


"WB" <WB@discussions.microsoft.comwrote in message
news:F5**********************************@microsof t.com...
>I'm just starting out with C# after many years with VB 6.0.

I'm trying to fill a listbox with a list of computer names (almost 100)
from
>app.config. First, is app.config the place to store and retrieve this
large
>list?

If so, I'm looking for code to obtain the list of computer names from
app.config, and also an example of how the computer names need to be
listed
>in app.config.

Thanks,
--
Bill Baker


Aug 8 '06 #5

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

Similar topics

3
by: ali poursadri | last post by:
Hi, I want to fill my list box from a dataset in c#. I use adapter and fill command and bind it to a listbox, but it is very slow for large data about 500000 records. How can I view this list...
3
by: Hrvoje Voda | last post by:
How to Fill a listbox with data from database? Hrcko
0
by: AndyAFCW | last post by:
I am developing my first .NET application that connects to a SQL Server 2000 database and I am having a total nightmare :x :evil: I am running Windows 2000 with Visual Studio .NET version...
6
by: William Sullivan | last post by:
I want to fill a cell in a table with a control. Lets say the control is a listbox--something that you'd think would easily fill a cell, which would be a good thing. So I create the table and...
1
by: Siegfried Heintze | last post by:
I'm using a third party hosting service. I presently have a Web Service on this hosting service's server that loads and executes a native mode DLL. This demonstrates that the hosting service has...
3
by: Rich | last post by:
Hello, I am just starting out with VB.net. I need to fill a listbox with data from an MS Access mdb file. What I tried was to create/add an ole connection object, then added an ole adapter...
0
by: The Zakman | last post by:
Please help me with a listbox and postback issue that has me baffled. I am storing my database connection strings in my web.config. At page_load, the db strings that are currently stored in the...
1
by: Steve Richter | last post by:
I have a form. In the Form is a MenuStrip and a FlowLayoutPanel. In the FlowLayoutPanel is a ListBox. The FlowLayoutPanel is set to DockStyle.Fill. The ListBox is set to AnchorStyles.Left |...
1
by: Peter van der Zee | last post by:
L.S., I'm want to fill a Listbox with class Array "records" based on certain criteria. The idea is to be able to select one "record" at the time, modify the data, and display this "changed"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
0
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,...
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,...
0
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...
0
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
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
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,...

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.