|
I want to have a textbox in which the user can enter only nos. In vb.net we can match the pattern by using the like operator followe by the preferences (e.keyChar Like "[0-9.]"). But how can i do it in C#
Plz give me a hint.
Best Regards,
M. J. Jaya Chitra
|
|
|
|
|
You can use a maskedtextbox, or use regex, or use char.IsDigit, etc, in a key pressed event handler.
e.KeyCar LIKE "[0-9.]" is doing a regex pattern match, which is wasteful compared to char.IsDigit, but with different syntax, it works fine in C#.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
How about using RegularExpressionValidator control of C#?
-- modified at 4:25 Tuesday 5th June, 2007
Regards,
Murali
|
|
|
|
|
That does something entirely different, a regular expression validator tells you if your input was formatted correctly. He wants the control to not allow invalid input.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I have to allow only the nos so I tried by checking the keyvalue so it is checking fine but it should not be allowed to be in the textbox know but whenever i am setting e.keyvalue=0, it is giving that it is a read only property, so plz give me a hint how to disable the invalid characters and to allow only nos and .(dot).
Best Regards,
M. J. Jaya Chitra
|
|
|
|
|
if (!char.IsDigit(e.KeyChar) && e.KeyChar != '.')
{
e.Handled = true;
}
Something like that. setting handled to true stops the base class from handling the key press ( so it is then ignored )
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thank you so much it is working well and good.
Once again Thank you
Best Regards,
M. J. Jaya Chitra
|
|
|
|
|
When we implement the dispose pattern, in protected virtual void Dispose(bool disposing), we need to say if disposing is true, then dispose managed resources as below:
protected virtual void Dispose(bool disposing)
{
if (!this.disposed)
{
if (disposing)
{
}
}
disposed = true;
}
When we make a call explicitly to this method with disposing = true, in public void Dispose() as below:
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
the managed resources will be explicitly disposed. But why do we need to dispose managed resources explicitly in protected virtual void Dispose(bool disposing). Won't they be disposed automatically by the GC finally after the object reach the end of its life?
Secondly, since those are managed resources, how can we get our own hands on to release them? For example, if we allocate some chuncks of memory on heap (i.e, instantiate classes), is there a way for us to release them explicitly? (Setting the references to nothing doesn't mean that, it just tells .Net that we don't need them any more, they can be recollected from this point of time. And this is actually unnecessary. Right?)
Thanx a lot.
-- modified at 20:00 Tuesday 5th June, 2007
|
|
|
|
|
Because you have no idea when the GC will be called, and the Dispose pattern is used to free unmanaged resources like bitmaps or database connections, so you can count on them becoming available right away.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
cateyes_99 wrote: Setting the references to nothing doesn't mean that, it just tells .Net that we don't need them any more, they can be recollected from this point of time.
But what about other managed objects that wrap unmanaged resources. Things like File, Pen etc.? For example :-
class TheDisposable : IDisposable
{
IntPtr handle;
FileStream stream;
public void Dispose
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
stream.Dispose();
}
CloseHandle(handle);
}
~TheDisposable() { Dispose(false); }
}
If you don't explicitly dispose the stream here, you'd have to wait for the finalizer for that particular FileStream object to run (assuming it has a finalizer).
Like you said, there is no need (usually) to set references to null in Dispose, as the GC is intelligent enough to figure out that an object has no live references.
|
|
|
|
|
Thanks. It makes much clear
|
|
|
|
|
hi..
in a class method like example : methodname(work obj) i pass the parameter of work object.
in that method i want to use the properties of message class like this
sms.ud = work.msg.Content
suggest me the best way so that i can proceed
|
|
|
|
|
What's the issue exactly ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
English please
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
i've created thumnail of picture from a folder
i wanna know the name of the picture that i've clicked on
then i added an EventHandler to each pic but when i used a ImageLocation they don't return anything
so please help
public void pb_Click(object sender, EventArgs e)
{
if (pbSel != null)
pbSel.BorderStyle = BorderStyle.None;
PictureBox pb = (PictureBox)sender;
pb.BorderStyle = BorderStyle.FixedSingle;
pbSel = pb;
string test ="test";
com_image.Text = pb.ImageLocation+"test";
}
thanks
|
|
|
|
|
An image does not store it's path internally.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
PictureBox.ImageLocation will be set automatically only by PictureBox.Load(URL).
When you load the image and calculate the thumbnail you could store the filename
yourself in PictureBox.ImageLocation; then you can retrieve it afterwards...
|
|
|
|
|
I am having 4 panels in my windows form. In that at a time only one panel has to visible and others has to be hidden. I tried it by setting the visibility as true for one panel and false to others but while debugging the visibility is not setting to true and i tried by callinf bringtofront method that time also what i have set in the design time is coming but others are not coming to the front WHY?
Can anyone answer me plz?
note: in the design time all my panels visibility is set to true
Best Regards,
M. J. Jaya Chitra
|
|
|
|
|
M. J. Jaya Chitra wrote: I tried it by setting the visibility as true for one panel and false to others but while debugging the visibility is not setting to true
Well, that just plain can't be. Unless some of your panels are sitting inside some of the others ? Then disabling an outer panel will disable the inner one.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thank you so much
Best Regards,
M. J. Jaya Chitra
|
|
|
|
|
i want to develop window in VC++ as a COM component and thene . use this component in .NET environment in C# client to put..control over that window..
how to do that..i wanna know..?
sam
|
|
|
|
|
You can import any COM dll into .NET and the framework will generate a class you can use to call it's methods. Seems lie a pain tho, what does C++/COM give you ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hello Everyone,
well I wanted to know how we can change the layout of the keyboard so that we can take input in Urdu language. and Actually I wanna take the input in the dataGridView in a Windows Application in C# 2.0
thanks in advance
Rocky
|
|
|
|
|
U have to install the urdu layout of your keyboard
then install the phonetic keyboard layout (only for your own convenience)
then u have to set your culture at design time or at runtime
and when u run your application u have to select urdu as a keyboard layout
that's all
|
|
|
|
|
OK that looks quiet helpful but can u plz tell me how we set the culture at design time or at runtime via a code example preferably
thanks a bundle
|
|
|
|