|
Hello Luc,
I also tried it, because I'm currious, but sadly it doesn't jump in the overriden method.
Tried it in the MainForm and in an UserControl.
protected override bool IsInputKey(Keys keyData)
{
return base.IsInputKey (keyData);
}
I read the msdn infos and know how it should work, but now I'm confused?
Any hints?
All the best and mercy,
Marin
-- modified at 11:45 Wednesday 28th February, 2007
Ok, just found out how to use it in an inherit TextBox for example:
protected override bool IsInputKey( System.Windows.Forms.Keys keyData )
{
switch ( keyData)
{
case Keys.Tab:
return true;
default:
return base.IsInputKey(keyData);
}
}
But it's not working on an UserControl or Form.
All the best,
Martin
|
|
|
|
|
Hi Martin,
Martin# wrote: But it's not working on an UserControl or Form.
What do you mean by this ? Is your IsInputKey() not called at all ? (for regular chars,
for TAB, arrows...) ? or is its return value simply ignored ?
And for which .NET version is this observation ?
I am using IsInputKey() on Panels only (both 1.1 and 2.0), no problem there.
|
|
|
|
|
Luc Pattyn wrote: s your IsInputKey() not called at all ? (for regular chars,
for TAB, arrows...) ?
Yes, in all points!
-- modified at 14:12 Wednesday February, 2007
I'm just rereading what I was answering before.
I think it was not clear.
What I meant, was that it is never called!
-- modified at 5:09 Thursday 1st March, 2007
I'm only using 1.1
|
|
|
|
|
I tried it too,
I override the IsInputKey method for the FORM, and the method was not called.
According to MSDN, it should be called.....
|
|
|
|
|
I have a weird problem. I have a VERY simple application that has been associated with a extension of .tix on my computer. Basically I want it when I open this .tix file, it sends the contents of the file thru the serial port. All the application has to do is send the data, and then close so there is no need for a form or anything else. What I have done is created a simple desktop application and in the Program.cs file I changed it to the following code. Just for testing I have hard coded in the contents of the .tix file into the variable TicketText. In Visual Studio when I run the application in debug mode I get a MessageBox that says "Ticket Printed-" and the application closes. The information is sent correctly thru the Serial Port as it should. When I load a .tix file then nothing is sent to the serial port. What is the difference?
<br />
static void Main(string[] args)<br />
{<br />
string TicketFileName = ""; <br />
try<br />
{<br />
TicketFileName = args[0].ToString();<br />
}<br />
catch { }<br />
<br />
SerialPort sp = new SerialPort();<br />
<br />
string TicketText = "Brad Presents BX3";<br />
<br />
sp.PortName = "COM4";<br />
sp.BaudRate = 1200;<br />
sp.Parity = Parity.None;<br />
sp.DataBits = 8;<br />
<br />
sp.Open();<br />
sp.WriteLine(TicketText);<br />
sp.Close();<br />
<br />
MessageBox.Show("Ticket Printed-" + TicketFileName.ToString());<br />
<br />
Application.Exit();<br />
}<br />
|
|
|
|
|
Brad Wick wrote: When I load a .tix file then nothing is sent to the serial port. What is the difference?
Hard or even impossible to say without seeing the code that loads the file.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hi,
it is in general a bad idea to ignore exceptions, which is what you do when specifying
an empty catch block. I suggest you put all your code in one try block, and
show the full exception.ToString() text in a messagebox when things go wrong (i.e.
inside the one and only catch block).
That will probably lead you straight to the heart of your problem.
|
|
|
|
|
My best guess at this point is that the call to Application.Exit() is causing a problem in release mode. If the application is exiting in any case, this call is unnecessary.
Phil
|
|
|
|
|
Using DirectX.Capture I lately found out that there is a problem in Lip movement and voice synchronization, i.e. when I apply Video Compression and without applying audio compression, say for example Microsoft Video 1, I found out that the voice and the lip movement does not match, sometime the voice/sound came out after the lip movement or vice-versa. What is the problem with these and how do I solve this problem. I will be very happy to get answer for this query.
Thanks in advance.
Suan Ngaihte.
|
|
|
|
|
1.I am wondering what is the need for attribute
if I have mechanisem calles interface to show behavior of classes?
2 . I saw some application that adding option in EXCEL FILE menu
how can I do this? (like after SAVE to add another option)
thanks
|
|
|
|
|
groundzero111 wrote: 1.I am wondering what is the need for attribute
if I have mechanisem calles interface to show behavior of classes?
Attributes are used for associating information with code elements. You can add attributes to most any code element, like types, methods, properties, classes.
Interfaces are used for defining a set of properties and methods. An interface is implemented by inheriting it, so it can only be done by classes or structs. An interface is similar to an abstract base class.
---
single minded; short sighted; long gone;
|
|
|
|
|
You are right about general use of attributes vs interfaces.
But then you have interfaces like INamingContainer[^]. It could as well be attribute. I wonder what's the reason why INamingContainer isn't attribute but interface. Well, maybe, maybe it's because interface express contract (in this case class implementing INamingContainer promises it will be able to provide unique names for its children. ) while attribute just adds metadata.
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
|
|
|
|
|
An interface works as a base class in the respect that you can create a reference to an interface, and use that reference for any class that inherits the interface. That enables you to use the members in the interface without needing to know the actual class of the object.
---
single minded; short sighted; long gone;
|
|
|
|
|
You missed the point, INamingContainer doesn't add ANYTHING to class implementing it, it's just marker. You do not use things as INamingContainer , you just ask them if they are INamingContainer . So from "how it works" point of view it could as well be attribute.
Guffa wrote: An interface works as a base class in the respect that you can create a reference to an interface, and use that reference for any class that inherits the interface.
I know how interface works, and I know how base class works.
Guffa wrote: class that inherits the interface.
You do not inherit interface, you implement interface. Inheritance express that something is specialization of base class, while implementing interface express that two possibly unrelated things have same capabilities (described in interface). That's little semantic difference.
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
|
|
|
|
|
Hello All ,
Is There any way to Convert the Date in one Format to Another Format
I am taking Date in dd/MM/yyyy Format from my Calender to TextBox
Now I need to take this date from TextBox as a string and Convert to dateTime (i.e Convert.TodateTime(TextBox1.Text)) Having MM/dd/yyyy(i.e.System Specified ) Format
Thanks for any help anyone is able to give me.
|
|
|
|
|
Hi
For datetime function, it always take this format MM/dd/yyyy.
Call this function (added below) if your date format is dd/MM/yyyy:
public string ParseDateTime(string StrDate)
{
String StrReturnDate = "";
String StrDay = "";
String StrMonth = "";
String StrYear = "";
StrDay = StrDate.Substring(0, 2);
StrMonth = StrDate.Substring((StrDate.IndexOf("/") + 1), 2);
StrYear = StrDate.Substring((StrDate.LastIndexOf("/") + 1), 4);
StrReturnDate = StrMonth + "/" + StrDay + "/" + StrYear;
return StrReturnDate;
}
Harini
|
|
|
|
|
Try this:
string DATETIMEPATTERN = "dd/MM/yyyy";<br />
string strdate = "28/02/2007";<br />
DateTime mydatetime;<br />
DateTime dt;<br />
DateTime.TryParseExact(strdate, DATETIMEPATTERN, null, DateTimeStyles.None, out dt);<br />
mydatetime = dt;
V.
I found a living worth working for, but haven't found work worth living for.
|
|
|
|
|
Hi,
if you getting the date as dd/MM/YYYY format(e.g, 31/01/2007) convert it to the .NET compliant date format like, 31/JAN/2007. You can simply do so by calling the function GetMonth.
string dateValue = "31/01/2007";
string month = GetMonth(dateValue.Split('/')[1]);
Then perform the following
DateTime.Parse(stringDateTime);
You can easily set the datetime for the corresponding string
public string GetMonth(string monthNumber)
{
string [] monthName = {"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Nov","Dec"};
return monthName[Int32.Parse(monthNumber)- 1];
}
-- modified at 4:58 Wednesday 28th February, 2007
Mohan
|
|
|
|
|
What you're saying doesn't make a great deal of sense as a DateTime is a DateTime is a DateTime, formatting is irrelevant. Do you actually mean that you want the string equivalent of a DateTime string value in an alternate string format? EG;
<br />
private string FormatDateTimeString( string dateTimeString )<br />
{<br />
DateTime dateTime = DateTime.Now;<br />
if( DateTime.TryParse( dateTimeString, out dateTime ) )<br />
{<br />
return dateTime.ToString( "MM/dd/yyyy" );<br />
}<br />
else<br />
{<br />
throw new FormatException( "The string value, (" + dateTimeString + "), passed to the 'FormatDateTimeString( string dateTimeString )' method is not a valid DateTime" );<br />
}<br />
}<br />
Rhys
ELYSIUM, n. An imaginary delightful country which the ancients foolishly believed to be inhabited by the spirits of the good. This ridiculous and mischievous fable was swept off the face of the earth by the early Christians -- may their souls be happy in Heaven!
Ambrose Bierce (1842 - 1914)
Behind every argument is someone's ignorance.
Louis D. Brandeis (1856 - 1941)
|
|
|
|
|
I m using this code.
http://support.microsoft.com/kb/312114
Problem is that when i closes the Server and send messages from Client.Exception generated because there is no server.How can I handle this in this code.Because there is no link between Client and Server.Both r accessing Remote Object.
|
|
|
|
|
Hi Michael,
Thanks for your Response. But I could not find
Open Source Forum Software in C#, PHP phpBB.com
If u dont mind direct me in a correct way so that it is easy for me to get the source code.One more thing i want to make clear i want the code in c#.
Thanks,
Ravindra
|
|
|
|
|
where is the Question man ?
you have posted new thread means no link with previous one .......
Please always reply ti the post instead of creating new one
<l>Thanks and Regards
Sandeep
|
|
|
|
|
I have been trying to learn C# in a classroom situation. I was given a problem that is supposed to be an OOP program.(I don't know enough to be sure.) The problem says that I'm to get an employee's name and the weekly sales amount. From that I need to figure out the gross pay, net pay, taxes, social security deduction and the retirement contribution. The only input is whats listed above. The other figures are based on constants. I would appreciate any help in steering me in the right direction. Supposedly the code I've written will work, I've based it on what is in the textbook.
My CLASS I've called Deductions. I've listed it below.
using System;<br />
using System.Collections.Generic;<br />
using System.Text;<br />
<br />
namespace Exercise_9_Chapter_4<br />
{<br />
public class Deduction<br />
{<br />
public string name;<br />
public double weeklySales;<br />
public double fedTax;<br />
public double socSec;<br />
public double retireAcct;<br />
public double grossPay;<br />
public double netPay;<br />
public double weeklySalesAmount;<br />
<br />
const double GROSS_WEEKLY_PAY = .07;<br />
const double FEDERAL_TAX = .18;<br />
const double SOCIAL_SECURITY = .06;<br />
const double RETIRE_ACCT = .10;<br />
<br />
public Deduction()<br />
{<br />
}<br />
<br />
public Deduction(string empName, double weeklySales)<br />
{<br />
name = empName;<br />
weeklySalesAmount = weeklySales;<br />
}<br />
<br />
public double SetGrossPay(double weeklySales)<br />
{<br />
grossPay = weeklySales * GROSS_WEEKLY_PAY;<br />
return grossPay;<br />
}<br />
<br />
public void SetFedTax(double grossPay)<br />
{<br />
fedTax = grossPay * FEDERAL_TAX;<br />
}<br />
<br />
public void SetSocSec(double grossPay)<br />
{<br />
socSec = grossPay * SOCIAL_SECURITY;<br />
}<br />
<br />
public void SetRetireAcct(double grossPay)<br />
{<br />
retireAcct = grossPay * RETIRE_ACCT;<br />
}<br />
<br />
public void SetNetPay()<br />
{<br />
netPay = grossPay - (fedTax + socSec + retireAcct);<br />
}<br />
<br />
public double NetPay<br />
{<br />
get<br />
{<br />
return netPay;<br />
}<br />
set<br />
{<br />
netPay = value;<br />
}<br />
}<br />
public double GrossPay<br />
{<br />
get<br />
{<br />
return grossPay;<br />
}<br />
set<br />
{<br />
grossPay = value;<br />
}<br />
}<br />
<br />
public double FedTax<br />
{<br />
get<br />
{<br />
return fedTax;<br />
}<br />
set<br />
{<br />
fedTax = value;<br />
}<br />
}<br />
public double SocSec<br />
{<br />
get<br />
{<br />
return socSec;<br />
}<br />
set<br />
{<br />
socSec = value;<br />
}<br />
}<br />
<br />
public double RetireAcct<br />
{<br />
get<br />
{<br />
return retireAcct;<br />
}<br />
set<br />
{<br />
retireAcct = value;<br />
}<br />
}<br />
<br />
public string GetName<br />
{<br />
get<br />
{<br />
return name;<br />
}<br />
}<br />
public double GetNetPay<br />
{<br />
get<br />
{<br />
return netPay;<br />
}<br />
}<br />
public double GetGrossPay<br />
{<br />
get<br />
{<br />
return grossPay;<br />
}<br />
}<br />
public double GetFedTax<br />
{<br />
get<br />
{<br />
return fedTax;<br />
}<br />
}<br />
public double GetSocSec<br />
{<br />
get<br />
{<br />
return socSec;<br />
}<br />
}<br />
public double GetRetireAcct<br />
{<br />
get<br />
{<br />
return retireAcct;<br />
}<br />
}<br />
<br />
}<br />
}
The next set is the program that is supposed to read the above material.
using System;<br />
using System.Collections.Generic;<br />
using System.Text;<br />
<br />
namespace Exercise_9_Chapter_4<br />
{<br />
class Exercise9Chapter4<br />
{<br />
static void Main()<br />
{<br />
<br />
string empName = DetermineName();<br />
double wkSales = DetermineWeeklySales();<br />
<br />
Deduction employee = new Deduction(empName, wkSales);<br />
<br />
employee.netPay = GetNetPay();<br />
employee.grossPay = SetGrossPay();<br />
employee.fedTax = SetFedTax();<br />
employee.socSec = SetSocSec();<br />
employee.retireAcct = SetRetireAcct();<br />
<br />
<br />
DisplayResults();<br />
}<br />
<br />
public static void DisplayResults()<br />
{<br />
Console.WriteLine();<br />
Console.WriteLine("Employee name is: " + employee.Name);<br />
Console.WriteLine();<br />
Console.WriteLine("The sales for this week are: {0:C} ", weeklySales);<br />
Console.WriteLine();<br />
Console.WriteLine("Your Federal taxes were: {0:C} ", fedTax);<br />
Console.WriteLine();<br />
Console.WriteLine("Your Social Security was: {0:C} ", socSec);<br />
Console.WriteLine();<br />
Console.WriteLine("Your retirement deduction was: {0:C} ", RetireAcct);<br />
Console.WriteLine();<br />
Console.WriteLine("Your net take home pay is: {0:C} ", netPay);<br />
Console.WriteLine();<br />
}<br />
<br />
public static double DetermineWeeklySales()<br />
{<br />
<br />
double weeklySalesAmount;<br />
<br />
Console.WriteLine("Type in weekly sales amount. ");<br />
string inputAmount = Console.ReadLine();<br />
weeklySalesAmount = double.Parse(inputAmount);<br />
return weeklySalesAmount;<br />
<br />
}<br />
<br />
public static string DetermineName()<br />
{<br />
string inputValue;<br />
<br />
Console.WriteLine();<br />
Console.WriteLine("Type in enployees Name.");<br />
inputValue = Console.ReadLine();<br />
return inputValue;<br />
<br />
}<br />
}<br />
}
When I try to rebuild it, I'm told that the Get statements in the Deduction employee = new Deduction(empName, wkSales); don't exist in the current context. The section in the DisplayResults tells me also that the names after the sentance also don't exist in the current context.
I thought I had writen this correctly, and that the program half was supposed to be able to read the Class.
Hopefully someone can tell me what it is that I'm doing wrong. Sorry that this has taken so much time. Thanks in advance.
|
|
|
|
|
Hi
1. You have declared the statement inside the main() method and the variable 'employee' is local.
Deduction employee = new Deduction(empName, wkSales);
2. Declare this variable outside main() method
static Deduction employee; and inside it should be chnaged to
employee = new Deduction(empName, wkSales);
3. Another mistake is that
employee.netPay = GetNetPay();
employee.grossPay = SetGrossPay();
employee.fedTax = SetFedTax();
employee.socSec = SetSocSec();
employee.retireAcct = SetRetireAcct();
Here remove brackets. You cannot assign use 'Set' on the right hand side as Set methods return type is void.
Check your code again and correct it
Harini
|
|
|
|
|
Whenever something "doesn't exist in the current context," it has not been declared within or is not accessible to the scope which tries to access it. You should be able to press F1 when you get the error message, or even see further explanation in intellisense/code completion, which should steer you to documentation that will give you examples of how something declared in one place may not be accessible to another. You may have declared a private or protected variable in the wrong class for instance, or maybe you wrote one of these methods in the wrong clas -- from which its trying to access data in the class it belongs in.
So this is how they teach? You get the code, and then you're supposed to do something with it?
What you're missing out on is the process of building all this. You can't be familiar with it if you can't build it, and if you can't build it, you aren't going to be any more effective than a poet with C# syntax. Don't cheat yourself. This is work. Believe it. The only way to make this simple for yourself is to find every answer you can by yourself. Believe me, in the end that's the fastest way.
You are typing this stuff out without even thinking about it. In the end, what your project tasks amount to, is calling methods which are already written for you.
That can't be very hard, can it?
(But I'm afraid it's really insulating you from what you need to get from this.)
|
|
|
|
|