|
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.
|
|
|
|
|
Thank you.Where in the program am i suppose to place List<int>?
|
|
|
|
|
Hi, everyone, i am a new member of this website. i encounted a problem in my GUI.
Right now i want to create a progressbar with pencentage done status running beside it. Can someone give me a hand? i appreciate it.
Peishen
|
|
|
|
|
Welcome!
There is a progress bar control available. You have to calculate the progress percentage and set that to Value[^] property of progress bar.
|
|
|
|
|
|
Try searching the articles - there must be 6+ articles on PBs
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
We have an existing application (so I can't make wholescale changes) that has a number of user controls that are displayed as follows:
Call a method (MyUserControl.ShowVaseline(Control parentControl) which
1. Creates a bitmap from the parentControl.
2. 'Grayscales' the bitmap
3. Creates an empty usercontrol with this bitmap as the background
4. Docks this newly created user control within the parentControl (so it LOOKS as if the parent control is disabled, whereas in fact it is invisible, hidden behind the newly created control)
4. Positions MyUserControl centrally within this newly created user control
The effect is that MyUserControl is shown on top of the parent control, will move with the parent control, and the parent control is disabled and appears 'greyed out'
In most cases this is fine and dandy for its purposes - which is essentially a desire to be able to access some top-level controls on the parent form at all times, while maintaining workflow through apparent modality of dialogs).
But when shown like this it is not 'Modal' in the Windows sense of the word - ie the code following MyUserControl.ShowVaseline(parentControl) is executed without waiting for MyUserControl to complete.
So the 'closing' of the user control is handled by it events which are handled by the parent :
...
MyUserControl.Close += MyUserControlClosed;
MyUserControl.ShowVaseline(Control parentControl);
}
private void MyUserControlClosed(Dialogresult dialogResult)
{
if (DialogResult.OK)
{
SoSomeStuff();
}
}
I would dearly like the ability to treat the control just like a modal dialog form, in some cases - so the LOOK would be the same (centered on an apparently disabled background) but I could do something like
DialogResult dialogResult = MyControl.ShowVaselineModal(parentControl);
if (dialogresult == DialogResult.Ok)
{
DoSomeStuff();
}
I don't really understand, technically, how a dialog form 'works' so don't really know where to begin.
I can think of having my main program enter a loop, checking the user control for a modal result
MyControl.ShowVaselineModal(parentControl);
while (MyControl.DialogResult == DialogResult.None)
{
Application.ProcessMessages();
}
if (MyControl.Dialogresult == DialogResult.Ok)
{
DoSomeStuff();
}
But surely there's something clever I'm missing?
Incidentally, the reason I want to do this is for the occasional situation where, for example, I am iterating a collection, and want to open a 'dialog' for (possibly) several items in the collection - with a true dialog I can just put the code in the loop - but using the existing Vaseline stuff, I have to faff about keeping references to where I am in the collection and/or what has been handled so I can continually reprocess the collection until I have done. It's not so much hard as annoying.
All help gratefully appreciated.
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
Wow - what dogs breakfast to you have to go through to disable a form. Why not just walk the forms control tree and disable/grey the controls, you could even replace the vaseline (what a horrible name, brings back memo... oops) with a UC to do the disabling.
Never underestimate the power of human stupidity
RAH
|
|
|
|