|
In a number column in Datagrid, I want to enter a negative number by using the NumPad "-" key. It does not work at all, but if I use "-" key in number row in the main key board, it works fine. After a further research, it seems that NumbPad "-" or "+" key does not fire a key_down or key_press event,(means no way to capture these two keys). Anyone knows how to solve it?
|
|
|
|
|
other keys are all working except "-" and "+".
|
|
|
|
|
See:
protected override bool ProcessKeyPreview(ref Message m)
protected override bool ProcessDialogKey(Keys keyData)
or other methods with Key in names.
Hi,
AW
|
|
|
|
|
Hi,
Should I be able to bind to a sub-property of a DataItem in a data grid?
i.e:
<br />
<%# DataBinder.Eval(Container.DataItem, "Product.Title") %><br />
It doesn't work for me. I get this message:
<br />
Exception Details: System.Web.HttpException: DataBinder.Eval:<br />
'POM.ProductDetails' does not contain a property with the name Title.<br />
But POM.ProductDetails does contain a Title Property!
The only way I can get it to work is to use a helper i.e.:
<br />
public string GetProductTitle(object Product)<br />
{<br />
POM.ProductDetails product = (POM.ProductDetails)Product;<br />
return product.Title;<br />
}<br />
This seems to be a very long way of doing it, especially if I have to do it
for every property!
Any ideas?
|
|
|
|
|
Hey everyone,
I'm still chugging away on my little game. Right now you can connect to a server and play across the internet. The 'game' works, but I'm having some serious issues with memory leaks.
I don't know when I should implement the IDisposable interface. Even when I implement it, it doesn't seem to make any difference at all. It seems the source of my problem are arrays and their values.
For example: I had an array of bullets. Whenever one bullet was spent and no longer being used, I would just simply call: bulletArray[i] = new Bullet(); and replace the old version of the object with a new one. This caused a very unwelcome memory leak that took me hours to track down. I thought I could just overwrite the old object but it turns out the system holds on to it indefinitely.
My next problem. I've recently started using ArrayLists. Whenever something was no longer needed, I would .Remove(ObjectNoLongerNeeded). Wouldn't removing the object also set it up for garbage collection? It doesn't seem to. What do I need to do to get rid of the old object and reclaim the memory?
This is my first C# program and the first time using a OO language. It's wonderful to see my program working, but whenever anyone shoots while connected their program's memory requirement permanently increases. Whenever anyone explodes, memory requirement goes up. I know this has to do with my arrays, but damn, there are so many of them. How can I get around this?
If I have a class called MyClass() that implements IDisposable, what do I need in the Dispose function to actually 'dispose' it? How do you dispose integers, floats, and other primatives?
Thanks,
EvilDingo
|
|
|
|
|
|
Interesting problem. You only need to implement IDisposable if you have either unmanaged resources (i.e. window or other object handles from the OS) or scarce managed resources (i.e. database connections). All other managed classes, including arrays, should be collected by GC periodically.
In fact, implementing IDisposable imposes a small performance penalty when it comes to garbage collection. Not that you should never do it, but only do it when necessary.
I have heard of other situations like this. I don't know if it was a problem with the Framework or simply sloppy programming. You may look into using structures instead of classes, if your classes are very simple and contain mostly primitives. Structures can have constructors, properties and methods. They are like light-weight objects, but are created on the stack instead of the heap.
HTH
|
|
|
|
|
Hi
I know this does not answer your question, but I hope you know about the problems with ArrayLists. If you dont know these problems, these are what they are. Once you have set up an array to hold a certain number of items, it works fine. When you start increasing the size dynamically, speed drops bigtime, especially if you have large arrays or lots of them. The way it works, is if it can store 10 ints, and you add another 1, it will make a new array, and copy all the items into it, and hopefully delete the old one.
|
|
|
|
|
Hey,
I have read this before it is possible to create an instance of a type
by specifying their string literal equivalent.
for example if i need to create an instance of Employee class
generally i will say Employee objEmployee = new Employee();
my question is i just know that the class which i need to instantiate is "Employee" how will i instantiate using the string "Employee"
hope i did not made the simple ques more complex.
Cheers,
Venkatraman Kalyanam
Chennai - India
"Being Excellent is not a skill, it is an attitude"
Reality is an illusion caused by caffeine deficiency(one Microsoft Research scholor)
|
|
|
|
|
Check out AppDomain.CreateInstance and AppDomain.CreateInstanceFrom
Rocky Moore <><
|
|
|
|
|
You can instantiate a class using a "partial" name... i.e. the type name as a string literal, one way is...
<br />
string path = "MyApp.MyAssembly";
string class = "MyClass";
<br />
object MyObj = Assembly.Load(path).CreateInstance(class);<br />
This is most useful when your class implements a known interface but you want to dynamically load the implementation because you can do the following.
<br />
IFooBar fooBar = Assembly.Load(path).CreateInstance(class) as IFooBar<br />
This stuff is my favourite thing about .net...
HTH
Shaun
-----------------------------------------------------------------------
Shaun Austin: .NET Specialist. Spreading the word of .NET to the world... well the UK... well my tiny corner of it!!
|
|
|
|
|
thanks for your info
Cheers,
Venkatraman Kalyanam
Chennai - India
"Being Excellent is not a skill, it is an attitude"
Reality is an illusion caused by caffeine deficiency(one Microsoft Research scholor)
|
|
|
|
|
Venkat,
Have a look at CreateInstance and CreateInstanceAndUnwrap method, I think you can also do this using other reflection techniques.
Cheers,
Kannan
|
|
|
|
|
thanks for your info
Cheers,
Venkatraman Kalyanam
Chennai - India
"Being Excellent is not a skill, it is an attitude"
Reality is an illusion caused by caffeine deficiency(one Microsoft Research scholor)
|
|
|
|
|
You could also use Activator.CreateInstance. This is much simpler that using AppDomain.CreateInstance, especially if the "Employee" class is in the same assembly. It also returns an Object instance instead of an ObjectHandle.
|
|
|
|
|
How do i load an image from resource?? I found 2 ways :
1) Using class Bitmap's constructor as shown below
public Bitmap(
Type type,
string resource
); What should i put for the type parameter?
2) Using class Bitmap's FromResource(...) method as show below
public static Bitmap FromResource(
IntPtr hinstance,
string bitmapName
); How do i get the instance of my application?
Weiye, Chen
When pursuing your dreams, don't forget to enjoy your life...
|
|
|
|
|
I have simply used:
new Bitmap(this.GetType().Assembly.GetManifestResourceStream("MyNameSpace.MyBitmap"));
Rocky Moore <><
|
|
|
|
|
Sorry for another question, but Im stumped on this: Im getting the following exception when I close my application:
An unhandled exception of type 'System.ObjectDisposedException' occurred in system.windows.forms.dll
Additional information: Cannot access a disposed object named "MainForm".
MainForm is the name of...my main form. It sounds like my main form is getting disposed for it actually should, but Im not explicitliy disposing it anywhere, and really dont have any idea where to look. Any ideas, or at least where to start?
Thanks
|
|
|
|
|
No problems with the questions... that's what these boards are for after all!!
Is it possible that you are either trying to access members of your form or objects created from it after the
Application.Run(new Form1());
line in your Main() function.
OR... do you have a timer which you have not stopped? It could be firing an event handler after the object which handles the event has been "disposed of"...
Some things to look for at least!
Shaun
-----------------------------------------------------------------------
Shaun Austin: .NET Specialist. Spreading the word of .NET to the world... well the UK... well my tiny corner of it!!
|
|
|
|
|
When a form is closed, it disposes of itself. You may still have a valid reference to the form and it won't be null/nothing, but it is a useless reference: any access to it results in ObjectDisposedException. Make sure you aren't trying to access properties/methods after it has closed.
|
|
|
|
|
Is there an equivalent for VB6's InputBox function in C#?
Nick Seng (the programmer formerly known as Notorious SMC)
God, I pity me! - Phoncible P. Bone
|
|
|
|
|
Its there in Microsoft.VisualBasic namespace, Interaction module.
InputBox[^]
Cheers,
Kannan
|
|
|
|
|
Thanks!
Nick Seng (the programmer formerly known as Notorious SMC)
God, I pity me! - Phoncible P. Bone
|
|
|
|
|
Hello friends,
I am trying to add a copyright symbol to a Label or TextBox within my About dialog. What I did was copying it from MS Word doc and paste it into Label or TextBox controls. It gave me this wierd char "ã", instead of the Copyright symbol.
Thanks so much
Khang Nguyen
|
|
|
|
|
private void button1_Click(object sender, System.EventArgs e)
{
string str="i'm some text " + Convert.ToChar(169);///169 is copyright symbol
MessageBox.Show(str);
string strString="now i'm text with registered " + Convert.ToChar(174);///174 is registered symbol
MessageBox.Show(strString);
}
just convert to char with the numbers and you will get the symbols , or paste them from character map .
switch(twinsOnWay)
{
case ("twins on the way"):
MessageBox.Show("for mr and mrs dynamic","twins on the way");
break;
|
|
|
|