|
i have created a button at runtime and want to form click event
handling during runtime.coding is like
class classname
{
Button b=new Button();
b.id=.......
b.Click += new System.EventHandler(_functionname);
...........
...........
...........
private void _functionname(object sender, System.EventArgs e)
{
Button bb=(Button)sender;
string urls;
urls=bb.id;
......
.........
}
}
but it is not working
Amit Kumar Katiyar
BhanuSoft tech Pvt. Ltd.
Noida
|
|
|
|
|
Have you added the dynamic control to the parent's controls collection?
class classname<br />
{<br />
Button b=new Button();<br />
b.id=.......<br />
b.Click += new System.EventHandler(_functionname);<br />
this.Controls.Add(b);
...........<br />
...........<br />
...........<br />
private void _functionname(object sender, System.EventArgs e)<br />
{<br />
Button bb=(Button)sender;<br />
string urls;<br />
urls=bb.id;<br />
......<br />
.........<br />
}<br />
}
|
|
|
|
|
thanks
but still its not working.this is a web application.
|
|
|
|
|
I need to destroy an object on the screen, there's only one of it and i just want it to die when i press a button
It is not created using an array or whatnot, because there will only ever be one.
Instead it is made using
character Maincharacter = new character (50, 50)
magical isnt it, but the only way i have found to remove an object (or a single intance of it) is by shoving it into an array, which i cant be bothered doing, so is there any other way it can be removed?
(there damn well should be, and if there isnt - someone should mae one )
|
|
|
|
|
how about Maincharacter = null
« Superman »
|
|
|
|
|
Good Day;
Does any one know a way to Reset/Change Passwords on mainframes?
Help will be appreciated;
Thanks;
|
|
|
|
|
What flavor of mainframe?
|
|
|
|
|
i wonder if there is a way to write a function using win32 API or .NET to automatically shut down windows xp when called.Then i can put the function in the comsumer application in WMI using the Start method to listen to the provider application which fires the event since the
System.Management provides the wrapper for WMI.
i am just curious about such an interesting problem.
welcome any advice
|
|
|
|
|
|
When implementing the IDisposable interface it is possible to use a class like this:
using ( MyClass myClass = new MyClass() )
{
...
} But it is also possible to use it without the using statement:
MyClass myClass = new MyClass();
... Question:
Is it possible to "force" a user of a class to always include it inside a using statement? (Maybe e.g. by applying some kind of attribute to that class)
--
Affordable Windows-based CMS for only 99 €: try www.zeta-producer.com for free!
|
|
|
|
|
AFAIK it isn't possible without some sort of code injecting/inspecting tool.
FXCop might have something like this already built in. And I know there is a free tool out there now for post compilation code injection, but I cannot remember the name of it now.
Beyond that, you could cheat the system a little bit and throw an exception from the Finalizer; just make sure your Dispose method calls GC.SuppressFinalize . If the Dispose method is never called on your object the exception thrown from the finalizer would alert them at some point in time about it..You would only want to do this in a debug build and probably need to capture a stack trace in the constructor so your exception thrown during Finalize can pin-point which object is causing the exception.
James
|
|
|
|
|
Great tip! Thank you, James!
--
Affordable Windows-based CMS for only 99 €: try www.zeta-producer.com for free!
|
|
|
|
|
Uwe Keim wrote:
Great tip! Thank you, James!
They don't call him Mister .NET for nothing!
Nish
|
|
|
|
|
Oh, I was unaware of that. BTW: Where is Heath?
--
Affordable Windows-based CMS for only 99 €: try www.zeta-producer.com for free!
|
|
|
|
|
Uwe Keim wrote:
Oh, I was unaware of that.
http://www.misterdotnet.com/blog[^]
Uwe Keim wrote:
BTW: Where is Heath?
Since he got Microsofted, he's been irregular in his posts
|
|
|
|
|
That reminds of a cute trick I learnt in C++. It is used to prevent people from mistakenly ignoring the return value of a function. Basically, it is a template class that has an implicit conversion to the actual return value of the function.
Off the top of my head,
template <typename T>
class Wrapper
{
T val;
bool used;
public:
Wrapper(const T &_val) : val(_val), used(false)
{
}
Wrapper(const Wrapper &w)
{
val = w.val;
w.used = true;
}
operator T()
{
used = true;
return val;
}
~Wrapper()
{
if (!used)
{
throw std::string("You forgot to use the return value");
}
}
};
Wrapper<bool> someFunc()
{
return false;
}
So bool v = someFunc(); will run smoothly, whereas someFunc(); will throw an exception.
Interesting use of destructors!
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
I am having a problem converting an object. I am new to C# with a C++ background. I modified some sample code to gain some experience with classes and the associative array. My goal is to create my custom class and use the associative array to house instances of that class. Most examples show how to view the data with the console.writeline method (works for me also), but I would like to place the information in a local field at the main level.
I can store various instances into the array and view them in the debugger, but I cannot access them through main as show below. I get the following error message: Cannot implicitly convert type 'object' to 'ConsoleApplication4.Checks.
I would really appreciate some help.
Thanks,
public class Checks;
{
public Checks(int RegisterID, int CatID);
{
:
:
}
}
public class Register
{
public Register(int size)
{
:
:
}
public object this[int RegisterID, int CatID]
{
get
{
string key = Convert.ToString(RegisterID);
key += Convert.ToString(CatID);
return KeyToObject(key);
}
set
{
:
:
}
}
protected object KeyToObject(string key)
{
for(int n = 0; n < _count; ++n)
{
Checks trankey = (Checks)_items[n];
if(key == trankey.key)
return trankey;
}
return null;
}
}
class Class1
{
static void Main(string[] args)
{
Register Pay = new Register (1);
Checks temp = new Checks (5,3);
temp.Description = "Vons";
temp.Amount = 30.50m;
Register [5,3]= temp;
temp = new Checks(6,2);
temp.Description = "Home Depot";
temp.Amount = 126.75m;
Register [6,2]= temp;
temp = Register [5,3];
}
}
cab3
|
|
|
|
|
Have you tried casting?
temp = (Checks) Register [5,3]
"I think I speak on behalf of everyone here when I say huh?" - Buffy
|
|
|
|
|
Dah, I must have been moving too fast. Thanks a lot, and yes that solved it.
cab3
|
|
|
|
|
Thanks for the help.The problem is that i am desinging my
own harware stereo fm radio which has a usb connector
which is plug into the usb port of the system,whether
i write driver for this particular device or dll for
using it in c#.Net and control it?.kindly tell me the
proper solution for the above query.waitng for your reply....
@hs@n
|
|
|
|
|
Hi,
Bit of a coincidence, I was just checking out usb stuff
at http://www.icsharpcode.com
check it out might be useful.
HTH
Web design and hosting
http://www.kayess.com.au
|
|
|
|
|
Thanks for your attention.
Currently I am working on a image processing program for PPC (using C#), yet there are two problems remained to be solved:
1. Rotating an image. Compact framework doesn't support the methods such as "Image.RotateFlip" or "Graphics.DrawImage(Image, Point[])", so I need to implement the rotation function completely by manually coding. Therefore I need an algorithm, which doesn't invoke any special system-provided method, to perform image rotation.
2. Saving an image. The compact framework doesn't support the Image.Save method, so I have to find another way to save a Bitmap object into a JPEG file.
Any kind of help will be greatly appreciated. Thanks.
|
|
|
|
|
Answering your first question
There are some image processing libraries on CodeProject, try to look at their sources.
You can try to research CxImage [^], there is an implementation of image rotation. Or you can try this one [^], written on C#.
|
|
|
|
|
Hi,
I am trying to grab a video clip from a movie in C# using DirectShow. I am using DirectShowNet project which I got from codeproject.com.It is working well when i am using devices like web cam etc .
I am getting problem in playing a movie which is stored on hard disk and capturing video clip from it.
An Exception is raised when SetupGraph() function is invoked from
RenderStream() function "Invalid Parameter".
I had used FilterCategory.LegacyAmFilterCategory as first argument to
DsDev.GetDevicesOfCat() function.And from the list of devices displayed by DeviceSelector class I am selecting 'File Source(async)'
|
|
|
|
|
Hi guys and gals,
I have a windows form with a DateTimePicker and a DataGrid. What I would
like to do is double-click a cell in the DataGrid and have that cell
update to show the date that is selected by the DateTimePicker.
Any suggestions as to how I could do this?
TIA
Steve
Web design and hosting
http://www.kayess.com.au
|
|
|
|