|
Thanks Senthil, I got it.
|
|
|
|
|
Hi
I would appreciate if somebody help me,because i m beginer in C#.
1)The property of my main form IsMdiContainer=True .I would like to change its color to white but I can not.
2)In my main form I add to buttom that when I press the first button the second form will show.but the buttoms also will show else I want them never shown when the second form is active.
thanks
|
|
|
|
|
hi
i create a windows application and i change main() method to following code :
(add parameter)
static void Main(string param1)<br />
{ <br />
System.Diagnostics.Process.Start(param1);<br />
<br />
Application.EnableVisualStyles();<br />
Application.SetCompatibleTextRenderingDefault(false);<br />
Application.Run(new Form1());<br />
}
but the following error shown me :
Error 2 Program 'C:\Documents and Settings\Hamed\My Documents\Visual Studio 2005\Projects\ExeControl\ExeControl\obj\Debug\ExeControl.exe' does not contain a static 'Main' method suitable for an entry point ExeControl
how to solve my problem ?
thanks
|
|
|
|
|
Try
static void Main(string[] args);
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
thanks dnh.
my problem was solved
|
|
|
|
|
So, why did you change the signature of the Main method in the first place?
|
|
|
|
|
I've been trying to extend the functionality of the "file property" page in Windows.
All I've come up with after an hours worth of searching is a possibility to ADD a new tab to the dialog (property sheet handlers).
What I'd want to do is to add some checkboxes and perhaps some other elements to the default property page tab. I know it has to be possible since I've seen one application doing just that.
I hope someone here can help me find a way to accomplish this.
thx
Ele
|
|
|
|
|
Hello everyone,
I am having some problem adding ContextMenu Control and I was wondering if I can get some help.
I have a ListView "listView1" which I am trying to add a menu once the right mouse click is clicked. I have added a ContextMenu control to the Form "contextMenuListView1" and have added three items to it.
I understand in order to activate this functionality I need to associate the context menu with the listView control on the form. Unfortunatly, I don't know where I can do it! I am looking into properties of the listView control but I am not seeing anything relevent.
Can someone be kind enough to tell me how this can be done?
Thank you for your help and have a great day.
Khoramdin
-- modified at 17:46 Sunday 8th April, 2007
|
|
|
|
|
Hi,
Khoramdin wrote: I am getting error
compile-time error ? read the error message and fix it
run-time error ? read the error message and fix it
cant find a solution ? publish the error message and someone will find a fix.
|
|
|
|
|
Hello All,
I'm looking to use the System.IO.FileSystemWatcher to watch a directory for changes. And then writes all these changes to the console for the life time of the applictaion.
Looking at the MSDN site i was able to sucessfully use this object to check for a change
(which it did fine for the first change).
So then i thought that i could get the object to check the folder periodically by putting the code in a loop and using Thread.Sleep to act as a timer.
here's something like the code :
<br />
FileSystemWatcher wa = new FileSystemWatcher(); <br />
<br />
try<br />
{<br />
int i = 0; <br />
wa.Path = "C:\\New Folder";<br />
wa.Renamed += new RenamedEventHandler(wa_Renamed);<br />
wa.EnableRaisingEvents = true; <br />
<br />
do<br />
{ <br />
System.Threading.Thread.Sleep(5000);<br />
Console.WriteLine("Checking....."); <br />
i++;<br />
}while(i <= 10);<br />
<br />
Console.WriteLine("Press \'q\' to exit");<br />
while (Console.Read() != 'q');<br />
The problem is that(at least as it seems to me) once the event _Renamed has been fired it won't fire again. Eventhough the loop is going on.
Btw if you haven't noticed i'm new to C# and to these boards. So, HI.
Thanks for any help or shoving in the right direction.
N/A
|
|
|
|
|
Dag Ylno,
your while loop lasts for some 50 seconds; during tht time the thread running it
is blocked; if it happens to be the UI thread, then other events will be suppressed
during that time. In fact it is a bad idea to execute Thread.Sleep() on the UI thread.
The FileSystemWatcher is firing events when requested to do so. So the real work
should occur in methods such as wa_Renamed.
If you want to periodically inform the user that your program is running, I suggest
you use a Windows.Forms.Timer to do that; it does not require Thread.Sleep(), it
simply calls a user supplied method (the "tick handler") either once or periodically,
executing it on the UI thread, hence not wasting any resources and not blocking
other events.
Hope this helps.
|
|
|
|
|
Thanks for the reply Luc.
I got the thing to work in the end. I just needed to do the following(disable and then re-enable:
<br />
private static void WatchFolder(ref FileSystemWatcher wa)<br />
{<br />
Console.WriteLine("Checking..........");<br />
wa.EnableRaisingEvents = false;<br />
wa.EnableRaisingEvents = true;<br />
}<br />
You were saying in your reply that instead of using the Sleep function i should use the Timer. Could you post a very simple piece of code to show how to use the timer to call a method at a specified time or interval?
Thanks again.
|
|
|
|
|
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
|
|
|
|