|
Google is your friend.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I think Java is better and harder.
Sajjad Izadi wrote: Is there any differences?
By Java :
You can run your program on both of Linux and Windows.
Java is faster , faster , faster.
|
|
|
|
|
Mohammad Dayyan wrote: Java is faster , faster , faster.
Are you sure ?
Seriously, it all depends on the programmer and how efficiently the program is written. A C++ program can be very slow if it is written poorly.
|
|
|
|
|
what have you done before? or what have you done so far?
If you are a beginner learn from some tutorials before doing that.
Even not beginner download some samples here.
Good Luck
nelsonpaixao@yahoo.com.br
|
|
|
|
|
when we create a asymmetric key pair where can i find the public key, to distribute.
|
|
|
|
|
if i have a string like "100-A",i want to autoincrement it like 100-A,100-B,100-C......100-Z,100-AA,100-AB,100-AC......100-AZ,100-AAA,100-AAB
......
CAN ANY ONE HELP ME TO DO CODE FOR IT??
I ALREADY DONE CODE LIKE
public string autogenrate1(string strauto)
{
object max;
string m;
int count = 0;
max = ExecuteScalar(strauto);
if (max == System.DBNull.Value)
{
m = "100-A";
return m;
}
else
{
string n = Convert.ToString(max);
string character = "";
for(int t=0;t<n.length;t++)>
{
if (n[t] >= 'A' && n[t] <= 'Z')
count++;
}
if (count == 1)
{
for (int i = 0; i < n.Length; i++)
{
character = n.Substring(i, 1);
}
switch (character)
{
case "A": character = "B"; break;
case "B": character = "C"; break;
case "C": character = "D"; break;
case "D": character = "E"; break;
case "E": character = "F"; break;
case "F": character = "G"; break;
case "G": character = "H"; break;
case "H": character = "I"; break;
case "I": character = "J"; break;
case "J": character = "K"; break;
case "K": character = "L"; break;
case "L": character = "M"; break;
case "M": character = "N"; break;
case "N": character = "O"; break;
case "O": character = "P"; break;
case "P": character = "Q"; break;
case "Q": character = "R"; break;
case "R": character = "S"; break;
case "S": character = "T"; break;
case "T": character = "U"; break;
case "U": character = "V"; break;
case "V": character = "W"; break;
case "W": character = "X"; break;
case "X": character = "Y"; break;
case "Y": character = "Z"; break;
case "Z": character = "AA"; break;
case "AA": character = "BB"; break;
case "BB": character = "CC"; break;
case "CC": character = "DD"; break;
case "DD": character = "EE"; break;
case "EE": character = "FF"; break;
case "FF": character = "GG"; break;
case "GG": character = "HH"; break;
case "II": character = "JJ"; break;
case "JJ": character = "KK"; break;
case "KK": character = "LL"; break;
case "MM": character = "NN"; break;
case "NN": character = "OO"; break;
case "OO": character = "PP"; break;
case "PP": character = "QQ"; break;
case "QQ": character = "RR"; break;
case "RR": character = "SS"; break;
case "SS": character = "TT"; break;
case "TT": character = "UU"; break;
case "UU": character = "VV"; break;
case "VV": character = "WW"; break;
case "WW": character = "XX"; break;
case "XX": character = "YY"; break;
case "YY": character = "ZZ"; break;
}
}
else if (count == 2)
{
for (int i = 0; i < n.Length; i++)
{
character = n.Substring(i, 1);
}
switch (character)
{
case "A": character = "AB"; break;
case "B": character = "AC"; break;
case "C": character = "AD"; break;
case "D": character = "AE"; break;
case "E": character = "AF"; break;
case "F": character = "AG"; break;
case "G": character = "AH"; break;
case "H": character = "AI"; break;
case "I": character = "AJ"; break;
case "J": character = "AK"; break;
case "K": character = "AL"; break;
case "L": character = "AM"; break;
case "M": character = "AN"; break;
case "N": character = "AO"; break;
case "O": character = "AP"; break;
case "P": character = "AQ"; break;
case "Q": character = "AR"; break;
case "R": character = "AS"; break;
case "S": character = "AT"; break;
case "U": character = "AV"; break;
case "V": character = "AW"; break;
case "W": character = "AX"; break;
case "X": character = "AY"; break;
case "Y": character = "AZ"; break;
}
}
string s = "100" + "-" + character;
return s;
}
BUT IT CAN NOT PROCEED AFTER 100-AZ......
|
|
|
|
|
Perhaps something like this:
<br />
private int index = 0;<br />
private List<int> l = new List<int>();<br />
<br />
private void Increment()<br />
{<br />
if (l[index] == 91)<br />
{<br />
l.Add(new int());<br />
index++;<br />
}<br />
else (l[index]++)<br />
<br />
Print();<br />
}<br />
</int></int>
<br />
private void Print()<br />
{<br />
string letters = string.Empty;<br />
for (int i =0; i < l.Count; i++)<br />
{<br />
letters += (char)list[i];<br />
}<br />
string s = "100 - " + letters.ToString();<br />
}<br />
<br />
I havent tested this so you may need to tweak it.
Mark Brock
"We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen
Click here to view my blog
|
|
|
|
|
Check out this code project article[^]. It's a base conversion class. If you convert base 26 (letters A-Z) to base-10, increment the converted value, and then convert it back to base-26, you'll have your answer.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hi All,
I'm creating a custom control that has a property of type String that takes a file path. When this property is being edited from the Properties Window I would like to open the File Dialog so the user can browse to the one they want. How can I do this?
Thanks.
|
|
|
|
|
you can try this sample code
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing.Design;
using System.Windows.Forms.Design;
using System.ComponentModel;
namespace testproperty
{
public class TestClass
{
public TestClass()
{
}
private int id;
[System.ComponentModel.Category("Main")]
[System.ComponentModel.DisplayName("ID of Class")]
public int Id
{
get { return id; }
set { id = value; }
}
private string fileName;
[System.ComponentModel.Category("Others")]
[System.ComponentModel.DisplayName("FileName to load")]
[BrowsableAttribute(true)]
[EditorAttribute(typeof(OpenFileDialogEditor), typeof(System.Drawing.Design.UITypeEditor))]
public string FileName
{
get { return fileName; }
set { fileName = value; }
}
}
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")]
public class OpenFileDialogEditor : System.Drawing.Design.UITypeEditor
{
public OpenFileDialogEditor() { }
public override System.Drawing.Design.UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
{
return UITypeEditorEditStyle.Modal;
}
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
{
using (System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog())
{
if (value != null && !string.IsNullOrEmpty(value.ToString()))
{
try { ofd.FileName = value.ToString(); }
catch { }
}
if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
return ofd.FileName;
}
return string.Empty;
}
}
}
}
look the FileName property of TestClass
hope it helps
dhaim
programming is a hobby that make some money as side effect
|
|
|
|
|
One of my articles might be able to help you with customizing the design-time events of user controls, it can be found here[^].
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my Blog
|
|
|
|
|
VS uses a property grid to show the properties of a control. You have to define the editors to use in your property, so when the grid access your class (by reflection), it knows what editor to use. The editors must be of the type UITypeEditor. You can sub-class it to create your own editors.
The file browser is the System.Windows.Forms.Design.FileNameEditor class.
You define the editor in this way:
[Editor(typeof(System.Windows.Forms.Design.FileNameEditor),typeof(System.Drawing.Design.UITypeEditor))]
public string YourProperty
{
...
You can find more information on this MSDN article.
BTW, you need to link the System.Design library to use the filename editor.
|
|
|
|
|
Hi.
I used a method to enable CTRL+A for selecting all text in a textBox.
But whenever I press CTRL+A I hear a BUMB sound
How can we disable it ?
|
|
|
|
|
By changing the system sounds or turning the volume off, I guess.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Thank you,How can I do that ?
|
|
|
|
|
That's not a question becoming a programming forum. I believe that it's sufficiently described in the windows help.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thank you Guffa.
You're right, but I want to do that by C# programming
modified on Sunday, August 31, 2008 10:40 AM
|
|
|
|
|
Then you have to surrender some more information about what you have done. What method did you use to enable ctrl+A?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thank you Guffa.
This is my method :
private void textBox_KeyDown(object sender, KeyEventArgs e)
{
try
{
if (e.Control && e.KeyCode == Keys.A)
((TextBox)sender).SelectAll();
}
catch
{ }
}
|
|
|
|
|
How to create format string for decimal data type
which shows blank if number is zero and otherwize in default format?
I tried format string f;;# but this shows f for nonzero numbers.
Is it possible to create such string for .NET decimal ToString() ?
Andrus.
using System.Windows.Forms;
class AppMainEntry
{
static void Main()
{
// Expected: 0.40 actual: f
MessageBox.Show((0.40m).ToString("f;;#"));
// expected: 123.40 actual: f
MessageBox.Show((123.40m).ToString("f;;#"));
// expected: 123.4 actual: f
MessageBox.Show((123.4m).ToString("f;;#"));
// OK: expected: empty actual: empty
MessageBox.Show((0m).ToString("f;;#"));
}
}
Andrus
|
|
|
|
|
AFAIK you cannot mix standard format elements (f) in custom format so you'll have to create the whole format string. For example
(0.40m).ToString("###,##0.00###;-###,##0.00###;#")
|
|
|
|
|
For 1.1m your format shows 2 places after comma, but I want only 1 place as F.
Which custome format is exactly equivalent to F format ?
Andrus.
Andrus
|
|
|
|
|
If you want just one zero after comma, change the 0 to #:
(1.1m).ToString("###,##0.00###;-###,##0.00###;#") to
(1.1m).ToString("###,##0.0####;-###,##0.0####;#")
I'm not sure about F's format since I believe that it is affected by number settings in control panel. For more info Standard Numeric Format Strings[^] and Custom Numeric Format Strings[^]
Mika
|
|
|
|
|
F format behaviour on decimal is not affected by any settings:
0m returns 0
1.10m returns 1.10
1.1m returns 1.1
1.123m returns 1.123
How to obtain same behaviour with format string except zero is converted to blank string ?
Andrus
|
|
|
|
|
From the manual:
If format is null or an empty string, the return value of this instance is formatted with the general numeric format specifier ("G").
Simple test case:
System.Diagnostics.Debug.WriteLine("-------");
System.Diagnostics.Debug.WriteLine("Using F");
System.Diagnostics.Debug.WriteLine("-------");
System.Diagnostics.Debug.WriteLine("(0m).ToString(\"F\") => " + (0m).ToString("F"));
System.Diagnostics.Debug.WriteLine("(1.10m).ToString(\"F\") => " + (1.10m).ToString("F"));
System.Diagnostics.Debug.WriteLine("(1.1m).ToString(\"F\") => " + (1.1m).ToString("F"));
System.Diagnostics.Debug.WriteLine("(1.123m).ToString(\"F\") => " + (1.123m).ToString("F"));
System.Diagnostics.Debug.WriteLine("------------------");
System.Diagnostics.Debug.WriteLine("Using empty string");
System.Diagnostics.Debug.WriteLine("------------------");
System.Diagnostics.Debug.WriteLine("(0m).ToString() => " + (0m).ToString(""));
System.Diagnostics.Debug.WriteLine("(1.10m).ToString() => " + (1.10m).ToString(""));
System.Diagnostics.Debug.WriteLine("(1.1m).ToString() => " + (1.1m).ToString(""));
System.Diagnostics.Debug.WriteLine("(1.123m).ToString() => " + (1.123m).ToString(""));
System.Diagnostics.Debug.WriteLine("-------");
System.Diagnostics.Debug.WriteLine("Using G");
System.Diagnostics.Debug.WriteLine("-------");
System.Diagnostics.Debug.WriteLine("(0m).ToString(\"G\") => " + (0m).ToString("G"));
System.Diagnostics.Debug.WriteLine("(1.10m).ToString(\"G\") => " + (1.10m).ToString("G"));
System.Diagnostics.Debug.WriteLine("(1.1m).ToString(\"G\") => " + (1.1m).ToString("G"));
System.Diagnostics.Debug.WriteLine("(1.123m).ToString(\"G\") => " + (1.123m).ToString("G"));
results:
-------
Using F
-------
(0m).ToString("F") => 0,00
(1.10m).ToString("F") => 1,10
(1.1m).ToString("F") => 1,10
(1.123m).ToString("F") => 1,12
------------------
Using empty string
------------------
(0m).ToString() => 0
(1.10m).ToString() => 1,10
(1.1m).ToString() => 1,1
(1.123m).ToString() => 1,123
-------
Using G
-------
(0m).ToString("G") => 0
(1.10m).ToString("G") => 1,10
(1.1m).ToString("G") => 1,1
(1.123m).ToString("G") => 1,123
So are yuo actually looking for "G" like behaviour? AFAIK you must implement your own converter which has the knowledge of the actual input string.
|
|
|
|