|
hi ,
thanks but can you be bit more specific ie wer should i use this
thanks
C#
|
|
|
|
|
You should use it instead of Int.Parse() Have a look at documentatio in MSDN, it shows how to use Int.TryParse()
|
|
|
|
|
Hello,
I wrote the following code to get a list of available drives letters:
<br />
using System;<br />
using System.Collections.Generic;<br />
using System.Text;<br />
using System.IO;<br />
<br />
namespace drives<br />
{<br />
class Program<br />
{<br />
static void Main(string[] args)<br />
{<br />
int intFirstDrive = Convert.ToInt32('A');<br />
int intLastDrive = Convert.ToInt32('Z');<br />
List<int> intAvailableDrives = new List<int>();<br />
for (int i = intFirstDrive; i <= intLastDrive; i++)<br />
{<br />
intAvailableDrives.Add(i);<br />
}<br />
<br />
DriveInfo[] usedDrives = DriveInfo.GetDrives();<br />
int x = usedDrives.Length;<br />
<br />
foreach (DriveInfo usedDrive in usedDrives)<br />
{<br />
int intUsedDrive;<br />
string strUsedDrive;<br />
char chrUsedDrive;<br />
strUsedDrive = usedDrive.Name.Substring(0, 1);<br />
chrUsedDrive = Convert.ToChar(strUsedDrive);<br />
intUsedDrive = Convert.ToInt32(chrUsedDrive);<br />
intAvailableDrives.Remove(intUsedDrive);<br />
}<br />
<br />
List<string> strAvailableDrives = intAvailableDrives.ConvertAll<string>(delegate<br />
(int intDrive)<br />
{<br />
return Convert.ToChar(intDrive).ToString();<br />
});<br />
}<br />
}<br />
}<br />
but it seems that in windows vista DriveInfo.GetDrives() doesn't get network drives, is there something I can do about it?
|
|
|
|
|
|
Hello, everyone.
I was working on a windows program with C#, and wanted to associate my PictureBox component with a ContextMenu.
I searched into the Properties Windows, only to find a ContextMenuStrip property there instead of a ContextMenu.
Then I was unable to set the property using the Properties Window which would otherwise save me a lot of troubles.
So here comes my question. Since not all the properties of a component are displayed on the Properies Window, can I manually put the ContextMenu or some other property onto the Properties window? Or there's just no way for me to customize the Properties Window like that?
-- modified at 6:25 Saturday 20th October, 2007
|
|
|
|
|
ContextMenuStrip, is just a context menu, 'they' just changed the name a little.
Make yourself a ContextMenu(Strip) then set your Picture boxes ContextMenu(Strip) to it.
And in a situation where a property is not listed in the designer, and you KNOW its there, you can just add the line of code yourself, like:
this.Thing.Attribute = Whatever;
I don't think you can just add stuff tou the properties window like that. You'd have to inherit the base class, and add in the support for the designer.
My current favourite word is: Waffle
Cheese is still good though.
|
|
|
|
|
Thanks for your advice!
|
|
|
|
|
Hello,
In my application the date is stored in the table in dd/MM/YYYY. I want this date to convert based on the culture.
I have seen lot of example but they all start with current date time.
Please suggest.
Regards,
Pavas
-----------------------
[http://longjump.com/]
Dynamic business applications that manage and coordinate teams and information
-----------------------
|
|
|
|
|
whatever works for the current date time should also work for an arbitrary date time,
the conversion is independent of the actual value of the variable at hand.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
mpavas wrote: In my application the date is stored in the table in dd/MM/YYYY.
First of all, you should store the date as a date in the database, not text.
If you do store it as a date, it's not stored in any format at all. A date value never has a format, it's only when you render it as a string that it gets a format.
When you render the date as a string, you can specify a CultureInfo or DateTimeFormatInfo object to use, which specifies the culture or format. You can also specify an exact format string to use.
mpavas wrote: I have seen lot of example but they all start with current date time.
Yes, that's how most examples are written. They demonstrate how a method works, you just have to apply the same method to the data that you have.
---
"Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things."
-- Douglas Adams
|
|
|
|
|
He Gufa,
Thanks for the reply. I just got the solution and it follows the same guidelines as u provided
Thanks a lot
Regards,
Pavas
-----------------------
[http://longjump.com/]
Dynamic business applications that manage and coordinate teams and information
-----------------------
|
|
|
|
|
I Want To Load CrystalDecisions.CrystalReports.Engine To Make The Report Load Fast
ENG.M.Yahia
|
|
|
|
|
when live messager did not login, it showed a network diagnostic tool,
how to develope a diagnostic tool like live messager's?
|
|
|
|
|
Im using C# .NET 1.1. Im scratching my head over getting the regular expression to replace only a single instance of my pattern:
searchResults = Regex.Replace(searchResults, @"(]*)>)", "$1", RegexOptions.IgnoreCase);
searchResults contains HTML tags possibly containing two or more tags. I would like to append a tag just after the first and thats it. My above regex will append the tag after every on the page. How do i get it to do only the first instance and stop?
|
|
|
|
|
Create a RegEx object so that you can specify the options using the Options property, then the number of replacements in the call:
RegEx addHidden = new Regex.Replace(@"(<form ([^>]*)>)");<br />
addHidden.Options = RegexOptions.IgnoreCase;<br />
searchResults = addHidden.Replace(searchResults, "$1<input type=hidden name='mID' value=" + this.ModuleID + ">", 1);
---
"Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things."
-- Douglas Adams
|
|
|
|
|
Hello; Which event do I want for the following:
I would like to have a user click and hold the mouse button (left) down, and while it is held, they move a picturebox (c) around at the mouses position. Once they release, the box stays where it is.
My question is, which event is this? I didn't understand the drag events... So if anyone could help, I'd be greatly appreciative. Thanks in advance.
The most knowledge doesn't mean the most wise...
|
|
|
|
|
You'll need to handle 3 events: MouseDown , MouseMove and MouseUp .
/ravi
|
|
|
|
|
Could you give me an example?
The most knowledge doesn't mean the most wise...
|
|
|
|
|
See this[^] article. Although it's written in VB, the principles directly apply to your task.
/ravi
|
|
|
|
|
private Point offset = new Point(0);
private bool mouseDown = false;
private Point pt = new Point(0);
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
mouseDown = true;
offset.X = e.X;
offset.Y = e.Y;
}
private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
{
mouseDown = false;
}
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
if (mouseDown)
{
pt.X += e.X - offset.X;
pt.Y += e.Y - offset.Y;
pictureBox1.Location = pt;
}
}
Good luck,
Mike
-- modified at 18:38 Saturday 20th October, 2007
Life is not measured by the number of breaths we take, but by the
moments that take our breath away. "George Carlin"
|
|
|
|
|
Why doesn't this make a line that starts at 0,0, and ends where he mouse is? It worked a bit earlier, but now it doesn't.
private void Form1_Paint(object sender, PaintEventArgs e)<br />
{<br />
int x1 = MousePosition.X;<br />
int y1 = MousePosition.Y;<br />
<br />
Graphics A = e.Graphics;<br />
Pen BluePen = new Pen(Color.Blue, 3);<br />
A.DrawLine(BluePen, 0, 0, x1, y1);<br />
<br />
A.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;<br />
}<br />
<br />
private void Animator_Tick(object sender, EventArgs e)<br />
{<br />
this.Invalidate();<br />
}
This only works works if I invalidate in Form1_Paint , but then I get a low-quality image. Thanks in advance.
The most knowledge doesn't mean the most wise...
|
|
|
|
|
MasterSharp wrote: but now it doesn't.
what does "it doesn't" mean?
|
|
|
|
|
It means, that the form doesn't Invalidate() as far as I can tell. If you try that code (with a timer named Animator) and copy and paste it, you'll know what I mean. I want there to be a line connected to the cursor from 0,0 (don't ask why).
The most knowledge doesn't mean the most wise...
|
|
|
|
|
Hi,
some remarks:
1. Are you sure your tick is executed at all? Maybe you did something wrong with the timer.
2. Invalidate() will fail when not executed by the thread that created its object (this).
Make sure you are using the right kind of timer.
3. It is a bad idea to have a Paint routine that uses volatile inputs such as MousePosition:
the Paint handler will be called when you call Invalidate(), but also when Windows decides
it is necessary (e.g. because you are dragging another window over it, at which time the
mouse position does not make sense to your Paint at all).
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|