|
I am setting the data source of a combo box in the form constructor. the problem is that when the page is loaded and the data is being loaded in a combo box the selectedindexchanged event is being triggered. i don't want that to happen. how can I tackle that problem please?
Thanks for the help
|
|
|
|
|
A common problem. You can either set an internal flag that tells whether the combo is being loaded during initialization or disable the events and reenable them after the combo has been loaded.
only two letters away from being an asset
|
|
|
|
|
I am using a flag but the problem is that the selected value remains the same even though I change the selection. how can I solve that please?
|
|
|
|
|
What do you mean, "the selected value remains the same even though I change the selection"?
You're original question was how to work around the event firing during initialization. Now, however, it seems the problem is something else. If you want help around here state the problem clearly. Read the first post, How to get an answer to your question.
only two letters away from being an asset
|
|
|
|
|
Subscribe to the SelectedIndexChanged event after the page load?
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Hello. I'm im in the process of creating an IRC Bot. I want to have one window that has a GUI with buttons and the other to be a console window where all the output will be displayed. I was wondering if it is possible to use Console.WriteLine in a WinForms application and if so, how would I go about that? Thank you!
|
|
|
|
|
You can't use Console.Write but then again you don't have to. A TextBox, or ListBox even, properly formatted will look just the same.
only two letters away from being an asset
|
|
|
|
|
Ok. Thanks!
PS: Thank you again for the quick reply!
|
|
|
|
|
Console.Write/WriteLine writes to the Debug Output window. I don't know if it's possible to redirect this.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Console.Write writes to StdOut, which in the Visual Studio IDE is the debug window. In a console app, its the console window. You can mess around with setting the stdout but why bother when there are other methods available in a WinForms app.
only two letters away from being an asset
|
|
|
|
|
Hi,
Create a standard winforms project and then go to the project properties and change the output type to console. Magic, you'll have a console and a form.
Alan.
|
|
|
|
|
Hi,
I have internet connection to my desktop PC. I want to share internet from my desktop pc to Laptop using Bluetooth devices programatically.
Thanks,
Venky.
venki
|
|
|
|
|
|
hi all
i am currently using vs2005 c# window app , i am trying to make a crystal report base on the data i have in my ms sql database which i have binded programmically by using SqlConnection
thus i would like to know if i could use the same method to bind my database to the crystal report
so far i only done crystal report via data from a ms access database
is it possible? and any good keyword or hint for reference would be nice too
thanks
|
|
|
|
|
|
Can somebody please give me an example of a windows service that uses threading to look at a folder for files and if it finds a file then does some processing. Upon completion of processing looks again and continues... I don't know if it is wise to keep looking at a folder every second for files, please advice on that. If it is not then maybe put a wait and look every 20 minutes or so. Please help!!
I don't need code to look for files, etc. I just need some guidance on how to build the service with a thread.
Thank you in advance
Sameer
|
|
|
|
|
|
Hi again,
there is a FileSystemWatcher class that monitors changes to a folder or file; the problem with it (and with any other method of observation you could possibly come up with) is that it recognizes changes, rather than states, i.e. it will tell you a file got created, got written to, etc, but it is unable to signal a file has reached a new and consistent state (there is no FileClosed event or something similar).
The only really good way is for the file creator to signal you when a file create or update has been executed to completion.
I see no need to use threading, unless maybe if you want to watch several folders. You might want to tell us more about what the files are about, and what you intend to do to them.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hi Luc,
As always thank you for your response. My windows service in short looks at 3 folders for .csv files, parses them and does some database updating. From time to time there are files added to these folders so I have to keep looking at a certain interval in these folders (currently configured every 20 minutes)
I decided to implement the following method:
http://en.csharp-online.net/Creating_a_.NET_Windows_Service%E2%80%94Alternative_1:_Use_a_Separate_Thread[^]
Please let me know if this is not a good method, I would hate to crash the server because that is where this service will be loaded
Thanks
Sameer
|
|
|
|
|
We do exactly the same thing except we use a winforms app to give feedback to the user, it chacks every 2 minutes and disables the timer while checking (otherwise eyou get multiple threads)
We have implemented a delay in the reading of the file to avoid touching files still being written by setting a flag with the time of first seeing the file, if more than # period has elapsed since seeing the file we can then process it.
This has been working perfectly for the past 4 years, at 2am it processes up to 1200 files an hour.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi,
one way to overcome the problem you don't get events when a file creation/update is completed is this, assuming you're in charge of the producer's code:
- look for "event files", recognized by a specific characteristic, maybe a new file extension .EVE
- create/update your data files in any way you see fit; when done, create a short .EVE file containing the full path of the data file. Such file will be written atomically since it fits in a single sector.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Ok, there are multiple way to do that. As Luc suggested you can use FileSystemWatcher Class to check a folder. If any new files created it will fire an event and based on that you can do the required operation.
you can use TimerDelegate with windows service to monitor on a specific duration.
Recentenly I have completed a similar application. Please let me know if you have more doubts. Hope I can help you in this.
Thank you.
|
|
|
|
|
|
Samir,
That is fine. I have one question regarding your application. How file are submitting into the Folder? Is it submitted by any client? Is there any possibilites the more than thousand files created on that folder?
|
|
|
|
|
Happy to hear that it is a good method. A different client creates and dumps these files. Usually, there is a single file at one point and what my application is doing is processing these files and dumping it to an Archive folder.
Sameer
|
|
|
|