PC Review


Reply
Thread Tools Rate Thread

Create CheckBoxes

 
 
=?Utf-8?B?amV6MTIzNDU2?=
Guest
Posts: n/a
 
      17th Mar 2005
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

 
Reply With Quote
 
 
 
 
Carlos J. Quintero [.NET MVP]
Guest
Posts: n/a
 
      17th Mar 2005
> 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


 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      17th Mar 2005
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


 
Reply With Quote
 
=?Utf-8?B?amV6MTIzNDU2?=
Guest
Posts: n/a
 
      17th Mar 2005
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
>
>
>

 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      17th Mar 2005
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


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create checkboxes with FILLIN =?Utf-8?B?U2FyYWhX?= Microsoft Word Document Management 1 18th Jun 2007 05:21 PM
Create checkboxes programatically Ron Gibson Microsoft Access Form Coding 3 22nd Mar 2005 12:48 AM
Re: How do I create a macro to clear checkboxes? Mauro Gamberini Microsoft Excel Misc 2 14th Sep 2004 06:12 PM
Re: Using checkboxes and textboxes to create a document. Doug Robbins Microsoft Word Document Management 0 5th Jul 2004 02:04 AM
How to create in checkboxes automatically true Intruder Microsoft Excel Discussion 2 31st Jul 2003 10:10 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:35 AM.