|
Thanks but that does not help me
I simply created a new C# windows app, dragged a TabControl from the Toolbox and added two Tabpages.
Then I made to following changes to the resulting code:
public Form1 () {
InitializeComponent ();
this.tabPage1.Leave += new EventHandler ( tabPage1_Leave );
this.tabPage1.Enter += new EventHandler ( tabPage1_Enter );
}
void tabPage1_Enter ( object sender, EventArgs e ) {
Debug.WriteLine ( "tabPage1_Enter" );
}
void tabPage1_Leave ( object sender, EventArgs e ) {
Debug.WriteLine ( "tabPage1_Leave" );
}
I expect the Events to fire when the user selects a tabpage. That does not happen.
The same code imported with VS2005 works!
What can I do?
Michael
|
|
|
|
|
Hi,
i don't know when those events are fired (they are not the same as MouseLeave and MouseEnter) but if you want to fire an event when switching/selecting another tabpage you could use the TabControls "TabIndexChanged" event.
Make sure you REALLY fire the events. (maybe try mouseenter and mouseleave instead just to make sure that it works at all!)
|
|
|
|
|
mikone wrote: TabControls "TabIndexChanged" event.
The problem here is that the event is raised after the new tab is drawn. I can reactivate the previous page but then i see the page flicker.
What i want to do is prevent the page change.
My current solution is to override the OnSelectedIndexChanged(EventArgs e) method. But that looks awfully cumbersome given the fact that I should be able to page enter / page leave events. Only it does not work because there is a bug in .Net 1.1 that has been fixed in version 2.0
Cheers
Michael
|
|
|
|
|
how can we use isnumeric in c#
thanks
|
|
|
|
|
you could youse double.TryParse or int.TryParse - those methods take two arguments.
The first one is the value to parse.
The second one is the variable to write to (i guess its always passed as 'out' - look at the method header for further information)
The method will return true if the value could be parsed successfully.
|
|
|
|
|
but these meathods through exceptions which is a lag in performance
It is Good to be Important but!
it is more Important to be Good
|
|
|
|
|
Hello,
Amar Chaudhary wrote: these meathods through exceptions
No, thats not true.
That's the differents between 'Parse' and 'Convert.ToInt32'.
If it's possible for you you should use 'TryParse' in an 'if' == true statement.
All the best,
Martin
|
|
|
|
|
I really doubt MS would implement it as such but I would really like to see documentation on the way Int32.TryParse was implemented just so I can see for myself. I suppose, if I wasn't so lazy I could just look at the MSIL ... actually I think I am about to do that.
On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. - Charles Babbage
|
|
|
|
|
No try catch. I would post a snippet but it is way long. Int32.TryParse traces all the way up to Number.ParseNumber.
On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. - Charles Babbage
|
|
|
|
|
You can use this method as there is no built in methods.
private bool IsNumeric(object numberString)
{
string strVal = numberString.ToString();
char [] ca = strVal.ToCharArray();
for (int i = 0; i < ca.Length;i++)
{
if (ca[i] > 57 || ca[i] < 48)
{
if(ca[i] != 46 )
return false;
}
}
return true;
}
Ranjith Stephen
|
|
|
|
|
nice and should include 43 and 45 also
It is Good to be Important but!
it is more Important to be Good
|
|
|
|
|
u can try
private bool IsNumeric(object numberString)
{
string strVal = numberString.ToString();
char [] ca = strVal.ToCharArray();
for (int i = 0; i < ca.Length;i++)
{
if (Char.IsNumber(ca[i]))
return false;
else
return true;
}
}
rahul
|
|
|
|
|
Ithink you just check ca[0]
|
|
|
|
|
gr8 Rahul
Ranjith Stephen
|
|
|
|
|
ranjithlogics wrote: gr8 Rahul
Yes "gr8" indeed as in reading this makes me want to gr8 my forehead with a cheese gr8er.
Specifically
if (Char.IsNumber(ca[i]))<br />
return false;
within a method called IsNumeric - whose purpose is to return true when a string is numeric.
|
|
|
|
|
rah_sin wrote: for (int i = 0; i < ca.Length;i++)
{
if (Char.IsNumber(ca[i]))
return false;
else
return true;
}
This logic is so badly flawed..
1) false is returned if a character is numeric - the purpose of the method was supposed to be returning true if a caracter is numeric
2) It always returns on the first character, rather than checking the whole string is made up of numbers... basically the for loop is useless.
|
|
|
|
|
my aim was not to write codes for u rather to suggest the method
Char.IsNumber();
now its upto u that how can u use it for ur purpose
i think u people are smart enough to write ur ownn logics.
rahul
|
|
|
|
|
As has been hinted, rather badly, by previous posters the way to write an isnumeric method is to iterate over each character in a string checking whether Char.IsNumber is true or char == '.' for every character in the string.
You may want to remove formatting from the number, as often numbers may be separated with a comma (1,000,000) and sometimes numbers are a representation of currency (£100) - you may or may not want these two cases to be treated as valid numerics.
|
|
|
|
|
J4amieC wrote: As has been hinted, rather badly, by previous posters the way to write an isnumeric method is to iterate over each character in a string checking whether Char.IsNumber is true or char == '.' for every character in the string.
You also need to check for '-' in the first char, and that '.' only appears once.
|
|
|
|
|
Hi,
I would like to verify the version information of an installed application in a computer programatically (does any in built class in C# supports this). It would be great if you some one helps in this regard.
Thanks in advance:
Rakesh
Rakesh
|
|
|
|
|
Hi,
this depends on the kind of application you want to check. I dont know any other standard than file versioning (for executables and dlls) which would allow to retrieve such information. If you want to check applications installed by windows installer there is a way to retrieve the information by using wmi if i remember right. All together there is no "in-built" class for such things and as far as i know you will have to create your own classes to retrieve these information.
|
|
|
|
|
Thanks for responding,
My application do not use Windows Installer, so as per you I need to write a class of my own. So I would like to know how can I access these version info in my class, can you be broad in this...
Rakesh
|
|
|
|
|
I've been googling for retrieving the "standard" product version info of a exe/dll and found a forum post pointing to this article. The third example describes how to retrieve the version info by using the windows api (unsafe code). It's a bit complex but pretty self-explanatory. let me know if you don't get it and good luck so far
MSDN - C# Unsafe Code Tutorial
|
|
|
|
|
Hi!
In this case you can use the AssemblyName.Version property.
If you have the path to your assembly (doesn't matter if it's an exe or a dll), you can call AssemblyName.GetAssemblyName(pathToAssembly); to retrieve the AssemblyName instance.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
In My Application I have Three textboxes for phone number to maintain the format as 3-3-4.Once the user enters the first 3 numbers of a phone number the focus should automatically go to nextbox How can I do it in C#
chanti
|
|
|
|