|
Hi, I am using a simple forms timer in my Sokoban article.
CORRECTION: Sokoban uses a Thread, not a Timer.
Here is some example code that causes a timer to fire 100 times
(although a period of 1 msec is specified, it will actually be much slower,
see my timers article if you're interested):
public class CPTest_FastTimer {
System.Windows.Forms.Timer timer=new System.Windows.Forms.Timer();
int count=0;
DateTime start;
public void Run() {
start=DateTime.Now;
log("start = "+start.ToString("HH:mm:ss.fff"));
timer.Interval=1;
timer.Tick+=new EventHandler(timer_Tick);
timer.Start();
}
private void timer_Tick(object sender, EventArgs e) {
count++;
if (count>=100) {
log("got "+count+" ticks between "+start.ToString("HH:mm:ss.fff")+
" and "+DateTime.Now.ToString("HH:mm:ss.fff"));
timer.Stop();
}
}
}
-- modified at 20:34 Sunday 8th April, 2007
|
|
|
|
|
I'm looking for a C# function
string NumberToWords( Decimal d )
which returns amount by words, e.q.
NumberToText(100m) should return one hundred.
How to implement this ?
Andrus
|
|
|
|
|
|
This article[^] will show you how to implement what you ask for. It will also demonstrate how you can do that sort of thing for yourself in the future, too.
|
|
|
|
|
hi guys
i want to handle exceptions on dot net remoting , i want to handle exceptions in my client thrown by remoting server , any way ?
thanks in advance
hello
|
|
|
|
|
try/catch
only two letters away from being an asset
|
|
|
|
|
hi guys
i have a window service , but i want this to be appear in the task bar to start and stop and way to do that ,, thanks in advance
hello
|
|
|
|
|
ghumman63 wrote: but i want this to be appear in the task bar
Then it isn't a windows service. A windows service has no UI, so no window to appear in taskbar. The services management console is used to start and stop services.
only two letters away from being an asset
|
|
|
|
|
thanks,
ok lets say its a window application so how do i do that ?
thanks in advance
hello
|
|
|
|
|
I have a form and in this form I produce an sql command as textbox inputs. As using this sql command, show suitable data in crystal report. But I can't. How do we send this sql command into crystal report as a parameter? This is a very important problem for me. Please help me.
|
|
|
|
|
So, I just stumped myself here.
Basically I have a static function in a class which needs to add text to a TextBox in my main form. Can anyone suggest how I would go about referencing that TextBox control from the static class?
|
|
|
|
|
You shouldn't be referencing the text box from outside your form at all.
Two possible solutions.
Add an interface to the form class. Implement it. Have your static class access the form via the interface
e.g.
interface IMyPublicInterface
{
void UpdateSomeTextBox(string someValue);
}
public class MyForm : Form, IMyPublicInterface
{
public void UpdateSomeTextBox(string someValue)
{
this.someTextBox.Text = someValue;
}
}
public static SomeStaticClass
{
public static SomeMethodThatUpdatesTheUI(IMyPublicInterface theForm)
{
string someValue = "Generate the value for the textbox";
theForm.UpdateSomeTextBox(someValue);
}
}
Or you can use events for the same effect. See Passing Values Between Forms[^] NOTE: The concepts are valid between any classes, not just forms.
|
|
|
|
|
Ermmm.. This may be a silly question, but how would I go about calling that static method? What should the iMyPublicInterface theForm property contain?
-- modified at 14:06 Sunday 8th April, 2007
Edit: Nevermind. Just figured it out. For the benefit of anyone who might wish to know I used the following code to call my version of the interface:
<br />
EDIGui_StatusMessageInterface EDIInterface = (EDIGui_StatusMessageInterface)Application.OpenForms["EdiGUI"];<br />
EdiCore.sendNotificationToStatusLog(EDIInterface, "Has changes: " + myDriverDS.HasChanges() + "\n");<br />
Many thanks for the help.
-- modified at 14:08 Sunday 8th April, 2007
|
|
|
|
|
esulin wrote: Nevermind. Just figured it out.
Excellent.
One comment though. It is generally considered best practice to name all interfaces with an "I" prefix, e.g. IMyInterface
|
|
|
|
|
Hello!
I'm trying to send a "^" keypress to an application using SendKeys , i.e. not pressing the Control key, but sending a caret character.
Unfortunately, this doesn't work. According to MSDN, you need to enclose the caret in { } to send it, i.e. send "{^}". But this reproducably sends an & instead of a ^.
How to send a "^"?
Best regards
Dominik
|
|
|
|
|
hi
how to copy a small file to remote computer from network ?
thanks
|
|
|
|
|
Try with the help of the Socket class.
Get it[^]
Regards,
Satips.
|
|
|
|
|
thanks..
first : it is C++ code and how to use it in c#.net ?
second : i want to copy file to remote computer without any client app or ... on remote computer for accept connection (i want to remote file Invisible (hidely))
thanks
|
|
|
|
|
Copying a file to a remote computer without having the remote computer authenticate and accept the transfer would be a perfect vector for a virus or trojan. Fortunately, you can't do this, and if there were a way, no one here would help you because of the patently malicious intent of such an operation.
|
|
|
|
|
Hello everyone,
I am currently working on a DVD Playback Windows Application using C# and would like to add the option of grabbing image samples. My research led me to IsampleGrabber interface.
I was wondering if anyone knows a detialed step by step tutorial on ISampleGrabber interface using C# programming? Your help is greatly appriciated.
Thank you very much and have a great weekend.
Khoramdin
|
|
|
|
|
|
|
I'm using the following code to insert/update records to an Access database using a DataSet. (Don't worry too much about the 'EdiDatastore' class - I just use it to encapsulate some DB functionality - should be self explanatory).
Note that the DriverID is an AutoNumber field in the Access DB.
<br />
myDriverDB = new EdiDatastore();<br />
myDriverDB.open();<br />
myDriverDB.sqlCommand("SELECT DriverID, DriverName, DriverVersion, DriverDLL, DriverEnabled FROM Drivers");<br />
myDriverDB.makeDataAdapter();<br />
<br />
myDriverDB.dataAdapter.InsertCommand = myDriverDB.conn.CreateCommand();<br />
myDriverDB.dataAdapter.InsertCommand.CommandText = "INSERT INTO Drivers " +<br />
"(DriverName, DriverVersion, DriverDLL, DriverEnabled) " +<br />
"VALUES (?,?,?,?)";<br />
myDriverDB.dataAdapter.InsertCommand.Parameters.Add("DriverName", OleDbType.VarWChar, 255, "DriverName");<br />
myDriverDB.dataAdapter.InsertCommand.Parameters.Add("DriverVersion", OleDbType.VarWChar, 100, "DriverVersion");<br />
myDriverDB.dataAdapter.InsertCommand.Parameters.Add("DriverDLL", OleDbType.VarWChar, 100, "DriverDLL");<br />
myDriverDB.dataAdapter.InsertCommand.Parameters.Add("DriverEnabled", OleDbType.Boolean, 10, "DriverEnabled");<br />
<br />
myDriverDB.dataAdapter.UpdateCommand = myDriverDB.conn.CreateCommand();<br />
myDriverDB.dataAdapter.UpdateCommand.CommandText = "UPDATE Drivers " +<br />
"SET DriverName=?, DriverVersion=?, DriverDLL=?, DriverEnabled=? " +<br />
"WHERE DriverID=?";<br />
myDriverDB.dataAdapter.UpdateCommand.Parameters.Add("DriverName", OleDbType.VarWChar, 255, "DriverName");<br />
myDriverDB.dataAdapter.UpdateCommand.Parameters.Add("DriverVersion", OleDbType.VarWChar, 100, "DriverVersion");<br />
myDriverDB.dataAdapter.UpdateCommand.Parameters.Add("DriverDLL", OleDbType.VarWChar, 100, "DriverDLL");<br />
myDriverDB.dataAdapter.UpdateCommand.Parameters.Add("DriverEnabled", OleDbType.Boolean, 10, "DriverEnabled");<br />
myDriverDB.dataAdapter.UpdateCommand.Parameters.Add("DriverID", OleDbType.Boolean, 10, "DriverID");<br />
<br />
DataSet myDriverDS = myDriverDB.getDataSet("MyTable");<br />
<br />
DataRow driverDR = myDriverDS.Tables[0].NewRow();<br />
driverDR["DriverName"] = "Test";<br />
driverDR["DriverVersion"] = "0.0.0";<br />
driverDR["DriverDLL"] = "test.dll";<br />
driverDR["DriverEnabled"] = true;<br />
<br />
myDriverDS.AcceptChanges();<br />
myDriverDS.Tables[0].AcceptChanges();<br />
<br />
DataRow driverDR2 = myDriverDS.Tables[0].NewRow();<br />
driverDR2["DriverName"] = "Test";<br />
driverDR2["DriverVersion"] = "0.0.0";<br />
driverDR2["DriverDLL"] = "test.dll";<br />
driverDR2["DriverEnabled"] = true;<br />
<br />
myDriverDS.Tables[0].LoadDataRow(driverDR.ItemArray, true);<br />
myDriverDS.Tables[0].LoadDataRow(driverDR2.ItemArray, true);<br />
myDriverDS.Tables[0].AcceptChanges();<br />
myDriverDS.AcceptChanges();<br />
<br />
myDriverDB.dataAdapter.Update(myDriverDS, "MyTable");<br />
Application.DoEvents();<br />
<br />
myDriverDB.close();<br />
The problem is that the DataTable.LoadDataRow method doesn't actually execute any database commands (I have tested this by creating intentional syntax errors in the SQL insert and update commands - no exceptions are thrown). The DataSet itself shows the inserted values correctly.
I have tried removing the DriverID column from the DataSet, but that doesn't make a difference. Can anyone tell me why this code would not update the new rows in the dataset to the database?
|
|
|
|
|
Try this article
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Ok.. Took me a minute to figure out what you where referring to but I figured it out. Didn't know about the DataAdapter.Update(DataSet.GetChanges(),Table) syntax.
Thanks.
|
|
|
|
|