|
Hmmm random thought that was only in vb. weird that even in a button you use this.width, thought that would be talking about the button that the code was in rather than the form.
oh well, problem solved. thanks for the quick answer.
|
|
|
|
|
The code you are writing in inside the
public partial class YourForm : Form
{
} so anything in there refers to the particular YourForm instance or it's members, or in the case of static - the YourForm class as a whole. The fact that the code is inside an event handler for a button (Click or whatever) is irrelevant.
|
|
|
|
|
Karrottop wrote: thought that would be talking about the button
No that would be (sender as Button)Never underestimate the power of human stupidity
RAH
|
|
|
|
|
If you write the code in the form's code behind, and you want to access a button (say btnOK ), use:
this.btnOK.Width = xxx;
or simply:
btnOK.Width = xxx;
this in C# and Me in VB.Net refers the the current object where the method belongs.
|
|
|
|
|
what is equivalent of setw()in C#
setw() is in C++
|
|
|
|
|
Example:
In C you write:
int x=1;
cout << "Number:" << setw(20) << x << endl;
In C# you write:
int x=1;
Console.WriteLine(String.Format("{0:D}", x).PadLeft(20));
Cheer's,
Alex Manolescu
|
|
|
|
|
Or Console.WriteLine("{0,20}", x)
|
|
|
|
|
|
Hi, I want to add a "convert samplerate" function to a program that process wav files and I heard that Directshow already has such a function but I couldn't find any info. Does anyone know how to use it? Or is there any other options(without having to use other programs to convert it before loading the file)? (The program is written in C#.)
Thanks~
|
|
|
|
|
In C++ we have TrackPopupMenuEx() function to displays a shortcut menu at the specified location and tracks the selection of items on the shortcut menu.
How can i track the menu item selection in C#.
How can i archive similar functionality in C#.
Sample application appreciated.
|
|
|
|
|
In c# a context menu will be the similar one.
It has a Checked property that you could use:
treat the ClickEvent with something like this:
ToolStripMenuItem ts = sender as ToolStripMenuItem;
if (ts.Checked) { ts.Checked = false; }
else { ts.Checked = true; }
Now you can use a foreach or something to retrive the checked items. Something like:
foreach (ToolStripMenuItem item in contextMenuStrip1.Items)
{
if(item.Checked)
}
|
|
|
|
|
Hi,
I am new to C# , Please suggest the approach.
I have written below code .
public class A
{
public B obj = new B();
public delegate int delegateCalculate(int i, int j);
delegateCalculate dc ;
public int Add(int Num1 , int Num2)
{
return (Num1 + Num2);
}
public int Sub(int Num1, int Num2)
{
return (Num1 - Num2);
}
public void Display()
{
dc = this.Sub;
obj.Result(dc); //error
}
}
public class B
{
public int Num1 = 10 ;
public int Num2 = 20 ;
public delegate int Calc (int i,int j);
public int Result(Calc dc)
{
int ii = dc(Num1, Num2);
return ii;
}
}
The above code gives error for obj.Result(dc); call.
Please suggest how to call Result() of class B in class A.
|
|
|
|
|
One way to do this would be using the Action tag.
Have a look here[^].Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
Delegates are not equivalent when they just share the same signature, you could do this if you declare only one delegate type and use that in both places.
Delegate declarations do not have to be inside a class.
|
|
|
|
|
I want make a application that prints repports.
what is the best method to put data in word or modify word document?
from c# --> xml --> word or
c# --> word
or a another method?
|
|
|
|
|
|
double myVal = Math.Pow(10, 38);
txtResult.Text = String.Format("{0:n}", myVal);
double myVal = Math.Pow(10, 38) - 1;
txtResult.Text = String.Format("{0:n}", myVal);
Both of theme result is same;
100.000.000.000.000.000.000.000.000.000.000.000.000,00
But first example formula contain "-1"
|
|
|
|
|
This is a 'feature' of floating point numbers which are generally an approxmation of their integer values. While you can hold much larger (and smaller) values in double or float , you lose precision as a consequence. Refer to this article[^] for details. If you want large numbers with accuracy then you need to use BigInt or similar.MVP 2010 - are they mad?
|
|
|
|
|
That is because your myVal exceds the maximum value representable by a double(without the scientific notation).
If you use it with a smaller number => ok.
try using a decimal number and you'll see that it will thorw an exception(value too large).
Your value is actually 1.0E +38
|
|
|
|
|
Hi Guys,
I am writing an application where i need to log errors and some information,so for this i have written a class that is working perfectly fine when in debug and in re;ease mode but when i am making an exe and trying same application logs have not been written.
am using
string baseDir = AppDomain.CurrentDomain.BaseDirectory +
AppDomain.CurrentDomain.RelativeSearchPath;
to retrive the directory location...
can you guide me where i am lost.
Thanks
Vikasvikas da
|
|
|
|
|
Can u write down or Upload this class !
So we can see where is the problem ?
|
|
|
|
|
Hi,
check the value of baseDir;
does it end on a backslash?
does the folder exist?
can you create a file there?
why don't you use Environment.GetSpecialFolder? ApplicationData is probably what you want.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
Hi Luc,
while debugging i have checked the following
check the value of baseDir;
it comes with right path
does it end on a backslash?
yes it end with \\
does the folder exist?
yes the folder exist and it none but the base directory of my code path
can you create a file there?
yes files created there when running in debug or release mode
but when ever i am making an exe and installing it to another system files are not created.vikas da
|
|
|
|
|
You could try:
Application.StartupPath
The only difference is in the "\" so
Application.StartupPath => "C:\Data\Blah"
and
AppDomain.CurrentDomain.BaseDirectory => "C:\Data\Blah\"
As for the AppDomain.CurrentDomain.RelativeSearchPath :
if you do not create it specifically in code something like this:
domain.AppendPrivatePath("MyCustomAssembly");
it will return empty string.
|
|
|
|
|
tasumisra wrote: ,so for this i have written a class
Why reinvent the wheel? There are plenty good frameworks for this already like, Enterprise Library, whose pupose is to create a library of common tasks to save developers from having to recreate it each time. I know the language. I've read a book. - _Madmatt
|
|
|
|