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

Create CheckBoxes

Hi, I have a string array as follows

string[] databases = {"C:\Master.mdb", "C:\Toolbox.mdb", "C:\Import.mdb",
"C:\Library.mde", "C:\User.mdb", "C:\ImpData.mdb"};

I need some code that will check that the database file exists, and if it
does, to create a checkbox on a form for that database.

Thanks

Nov 16 '05 #1
4 1721
> I need some code that will check that the database file exists

Use System.IO.File.Exists()
to create a checkbox on a form for that database


Use Form.Controls.Add()

--

Carlos J. Quintero

MZ-Tools 4.0: Productivity add-ins for Visual Studio .NET
You can code, design and document much faster.
http://www.mztools.com
Nov 16 '05 #2
Jez,

You mean something as

\\\
foreach (string str in databases) if (File.Exists(str)) blabla;
///

http://msdn.microsoft.com/library/de...xiststopic.asp

I hope this helps,

Cor
Nov 16 '05 #3
Thanks for the advice. I now have the following, but I can't seem to set the
checkboxes width and location. The width needs to be 168 and the vertical
location needs to be 40 down from the previuos checkbox?

string[] databases = {"Master.mdb", "Toolbox.mdb", "Import.mdb",
"Library.mde", "User.mdb", "ImpData.mdb"};

for ( int j = 0; j < databases.Length; j++ )
{
if ( File.Exists(dbFolder + databases[j] ))

chk.Name = databases[j].ToString();
chk.Checked = true;
chk.Location = new System.Drawing.Point(j,chk.Location.X);
chk.Location = new System.Drawing.Point(j,chk.Location.Y);
chk.Text = databases[j].ToString();
chk.ThreeState = false;
Controls.Add(chk);
this.Refresh();

"Cor Ligthert" wrote:
Jez,

You mean something as

\\\
foreach (string str in databases) if (File.Exists(str)) blabla;
///

http://msdn.microsoft.com/library/de...xiststopic.asp

I hope this helps,

Cor

Nov 16 '05 #4
You mean something as this. (The checkboxes are created dynamicly starting
in the left most top and left position)

\\\
string[] databases = {"Master.mdb", "Toolbox.mdb", "Import.mdb",
"Library.mde", "User.mdb", "ImpData.mdb"};
for ( int j = 0; j < databases.Length; j++ )
{
//if ( File.Exists(dbFolder + databases[j] ))
CheckBox chk = new CheckBox();
chk.Name = databases[j].ToString();
chk.Checked = true;
chk.Location = new System.Drawing.Point(0, j * 20);
chk.Text = databases[j].ToString();
chk.ThreeState = false;
Controls.Add(chk);
this.Refresh();
}

I hope this helps?

Cor
Nov 16 '05 #5

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

Similar topics

2
by: Pete | last post by:
There is a Summary/Example further down... On page one of my site I have a form with some checkboxes and detailed descriptions. When the form is submitted (to page two), the values of the...
6
by: terence.parker | last post by:
I currently have the following JS in my header: function checkall(thestate) { var checkboxes=eval("document.forms.EssayList.file_id") for (i=0;i<checkboxes.length;i++)...
1
by: projectjakecs | last post by:
Hi, I am working on a ms access database and I am having trouble using a form to create new records in an associative table. Here is the breakdown of my database: Main Table - Computer...
2
by: Ken1 | last post by:
Hello, I have a list of checkboxes on a page... There is a certain list that is numbered from 1 to n which i want to be able to "check all/none" its easy to create this for all the checkboxes on...
10
by: rn5a | last post by:
All the rows in a DataGrid, including the Header, are accompanied with a CheckBox. I want that when the CheckBox in the Header is checked, then all the CheckBoxes should automatically get checked....
1
by: Petyr David | last post by:
Current: web page has hard coded directories (using checkboxes) user may choose to search for files matching a pattern they enter in text box. Perl is used to search for files and to format HTML...
5
by: masterej | last post by:
Developers, Is there any way to disable all checkboxes on a form? I have a form with 160 checkboxes and I want to be able to disable all of them. Is there a way I can do something like this: ...
8
by: PeteOlcott | last post by:
http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/grid/tests/test_change_structure.html I would like to completely understand how GUI controls such as this one are constructed. In the...
16
by: sarega | last post by:
Hi, There is an array whose length varies dynamically on the users input, I have to provide checkboxes for this array along with the value of the array and based on the checkboxes selected by the...
7
by: viki1967 | last post by:
I need one function javascript that: 1) when I enter in this htm page I see enabled only checkbox of categories A, M and T; checkboxes of microcategories all disabled; 2-a) If I select the...
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: 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: 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
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
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
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
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.