|
By the way, did you try to debug your code? Maybe you get an exception for this.
|
|
|
|
|
I made the following class:
public class MyTextBox : TextBox
{
private int _IntVariable = int.MaxValue;
private myEnum _EnumVariable;
public MyTextBox()
{
}
public int IntVariable
{
get {return _IntVariable;}
set {_IntVariable = value;}
}
public myEnum EnumVariable
{
get {return _EnumVariable;}
set {_EnumVariable = value;}
}
}
When I create a user control and place a "MyTextBox" control on the user control, I name it txtName and set the IntVariable to 7 and the designer shows 7. Then, when I build the solution again, the value shown in the designer resets to the maximum value of an integer while the code in the InitializeComponent() method still shows : this.txtName.IntVariable = 7;.
However, the enumeration property can be set and it persists when the solution is re-built, the UserControl is closed and re-opened in the designer, or Visual Studio is closed and re-opened and the solution re-opened.
Can anyone explain why the integer property is not persisting and the enumeration property is and if there is anything I can do to make the integer property persist in the designer?
|
|
|
|
|
Sorry, I can't replicate the problem. It behaves as expected here
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Hi,
I'm trying to build an over laying image like in the following link if you do mouse over Stars after Rate this Content you will see the overlaying form.
http://msdn.microsoft.com/hi-in/library/a72418yk(en-us).aspx[^]
I want to build same kind of control in C# Windows application? Is it possible ? Please help out.
|
|
|
|
|
IMO PictureBox which displays a Panel with needed controls on MouseHover might be a good start.
|
|
|
|
|
How to open a new File on a Button click such as an Application file.
|
|
|
|
|
Have you tried to Google[^]for it??
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
Use an OpenFileDialog, then open the file. How you do this depends on which file format it is. If you just want to open it, use Process.Start(fileName)
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
Rupaa wrote: How to open a new File on a Button click such as an Application file.
To do anything on a button click you will require event processing.
If you want to open a file specified by the user, so you need only a file path in string format, you could use OpenFileDialog.
If you want to open a file, so actually access it, which would mean you want its information. You can use
some .Net's classes inside of the System.IO namespace. They are ending with 'reader'. So what type of file access do you need?
If you want just only to execute a certain assembly executable, then I guess Process.Start(fileName) should be fine.
... I hope this helps!
|
|
|
|
|
can you help me to build an application use scanner to scan document
|
|
|
|
|
Yes I can.
My rates are $120 (US) per hour.
Let me know
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
_Maxxx_ wrote: My rates are $120 (US) per hour
Mine $119.50 (US) per hour
himanshu
|
|
|
|
|
Too expensive. I would do at $119. I can see you losing business.
|
|
|
|
|
How about 120 rupees??
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
If that's per second, I can manage.
|
|
|
|
|
For that you need to use the Scanner SDK to create your own scanning application. There are lots of 3rd party scannner SDKs available for you.
But if you need a simple application then this may help. .NET TWAIN image scanner[^]
Books are as useful to a stupid person as a mirror is useful to a blind person. - Chanakya
|
|
|
|
|
So I am trying to make a class that uses a constructor of a different class.
I use the code (Name of class) Class = new (Name of class(constructor variable))
But oddly the constructor variable won't appear. Could anyone please help?
|
|
|
|
|
Your question is not clear. Posting relevant code will help.
|
|
|
|
|
public class CharClasses
{
public int healthPoints = 0;
public int manaPoints = 0;
public int strength = 0;
public int dexterity = 0;
public int speed = 0;
public int intelligence = 0;
public CharClasses (string characterClass)
{
if (characterClass == "Warrior")
{
healthPoints = 100;
manaPoints = 10;
strength = 10;
dexterity = 5;
speed = 3;
intelligence = 0;
}
if (characterClass == "Archer")
{
healthPoints = 75;
manaPoints = 10;
strength = 3;
dexterity = 10;
speed = 5;
intelligence = 0;
}
if (characterClass == "Assassin")
{
healthPoints = 75;
manaPoints = 10;
strength = 5;
dexterity = 3;
speed = 10;
intelligence = 0;
}
if (characterClass == "Mage")
{
healthPoints = 50;
manaPoints = 50;
strength = 0;
dexterity = 5;
speed = 3;
intelligence = 10;
}
}
}
public class Leveling
{
public int level = 1;
public int experience = 0;
public Leveling()
{
if (experience == ((experience + 100) * 1.5))
{
level++;
}
}
}
I'm trying to take the constructor named "characterClass" from the class CharClasses and use it in the class Leveling.
CharClasses Class = new CharClasses(characterClass); I'm trying to make this code work but the characterClass part of it does not seem to work...
|
|
|
|
|
nik121 wrote: CharClasses Class = new CharClasses(characterClass); I'm trying to make this code work but the characterClass part of it does not seem to work...
Ok, Have you defined the variable characterClass in this scope? What is the error you are getting?
|
|
|
|
|
Yea characterClass was the string for the Constructor in the class CharClasses. But the characterClass says that it doesn't exist in the current context.
|
|
|
|
|
nik121 wrote: Yea characterClass was the string for the Constructor in the class CharClasses. But the characterClass says that it doesn't exist in the current context.
WOW! I am not sure how can I explain this to you. All you can do is to get a book and learn the basics.
When you write code like CharClasses Class = new CharClasses(characterClass) , compiler is expecting the variable characterClass to be presented in the scope. Here you don't have characterClass declared. You need to declare the variable first before using it. Something like
string characterClass = "Warrior";<br />
CharClasses Class = new CharClasses(characterClass);
|
|
|
|
|
If I understand your question, Leveling should inherit CharClasses and use the base constructor characterClass , as follows:
Leveling lvl = new Leveling("Warrior");
public class CharClasses
{
public int healthPoints = 0;
public int manaPoints = 0;
public int strength = 0;
public int dexterity = 0;
public int speed = 0;
public int intelligence = 0;
public CharClasses(string characterClass)
{
if(characterClass == "Warrior")
{
healthPoints = 100;
manaPoints = 10;
strength = 10;
dexterity = 5;
speed = 3;
intelligence = 0;
}
if(characterClass == "Archer")
{
healthPoints = 75;
manaPoints = 10;
strength = 3;
dexterity = 10;
speed = 5;
intelligence = 0;
}
if(characterClass == "Assassin")
{
healthPoints = 75;
manaPoints = 10;
strength = 5;
dexterity = 3;
speed = 10;
intelligence = 0;
}
if(characterClass == "Mage")
{
healthPoints = 50;
manaPoints = 50;
strength = 0;
dexterity = 5;
speed = 3;
intelligence = 10;
}
}
}
public class Leveling : CharClasses
{
public int level = 1;
public int experience = 0;
public Leveling(string characterClass)
: base(characterClass)
{
if(experience == ((experience + 100) * 1.5))
{
level++;
}
}
}
If you use inheritance, and don't need to instantiate CharClasses directly, you may want to change you your access modifiers from all public to protected , etc.
Regards,
Gary
|
|
|
|
|
Hello I am trying to read several different integers from a data file and then store each integer into a different variable.Does anyone know how to do this?
This is my program so far:
class Program
{
static void Main(string[] args)
{
string fileName, num;
int temp;
Console.Write("ENTer filename: ");
fileName = Console.ReadLine();
StreamReader inputFile = new StreamReader(fileName);
num = inputFile.ReadLine();
while (num != null)
{
temp= Convert.ToInt32(inputFile.Read());
Console.WriteLine(num);
num =inputFile.ReadLine();
}
Console.WriteLine("Press enter to end Program");
Console.ReadLine();
}
}
|
|
|
|
|
Use a List<int> and add the value each time in the loop.
|
|
|
|