I want to create a control on the form when the MouseDown event on the form fires and then use the MouseMove event on the newly created control to drag the control around the form. Unfortunately the MouseMove event doesn't appear to fire on the new control until the mouse button is released! ... This is the simplest cut down of the issue I could create.
Thanks for sharing your code Half-life! thats the most elegant implementation of the 'moving control' solution I have seen It still doesn't solve my problem though, which is getting that MouseMove event to fire on the newly created control before the Mouse button has been released
My problem had nothing to do with the control being new at all. When you MouseDown on the form, the form 'Captures' all subsequent mouse events until the next MouseUp... That is why my button control was not getting any events, the Form was stealing them!
The solution was to force the parent form to 'release' the capture so that the new button could receive the MouseMove event...
private void Form2_MouseDown(object sender, MouseEventArgs e)
Button button1 = new System.Windows.Forms.Button();
button1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.button1_MouseMove);
this.Capture = false; //Force the form to Release the Mouse!
Sorry for the vague title, but I have a scenario as below, which I am hoping to automate – but not really sure where to begin!
We have two c# windows applications:-
1) Creates XML files for order entry & places them on the network.
2) A user manually navigates to a section in another c# windows app to see if there are any xml orders to import.
I am wanting to write a new routine, which could be running in the background, that would check to see if any new xml files are placed on the network - if so can it mimic the steps which the user takes to import these xml orders?
I'm sure it can - I just dont know what to search for on google - any help would be much appreciated
FileSystemWatcher class would help in detecting new files automatically.
Easiest would be to amend your second program, so it gets the option to import
automatically. Creating a third program that manipulates the second's GUI is doable
but could be tricky, depends on what Controls the user has to manipulate when doing
it interactively. If the source of program 2 is available, I would modify it, and
not create a third program.
Well if you want this code to run in the background, the best solution is to create a service (New Project -> C# -> Windows -> 'Windows Service' template). The most robust way to get your service to 'watch' for new files is to employ a kind of 'find, move and process' strategy.
you need a
1) a 'drop' folder where the files will be initially written.
2) a 'process' folder where the files will sit between being found and being processed
3) an 'archive' folder where the files will go when your finished processing
The pseudo code for this looks a bit like this...
- list files in the 'drop' folder (keep this 'list' in memory somehow)
- move any found files to the 'process' folder
- process each found file in turn and move to the 'archive' folder when finished.
How is it possible to allow the results in this treeview control to be viewed/ordered either by items or by subitems. So that one can see all subitems for a particular item, or all items for a particular subitem?
u can but why?
hashtable gives u the ultimate key to value without "asking"
the datatable inside a dataset to give u information
here u just get the value u want from the hashtable Like :
hastable[key] and that it
where in a datatable u need to u use the select method
hastable are designed to be fast and one way in purpose
a generic collection Like :
u can create a Dictionary<TKey, TValue> with sepecific key type and value
or a list,
List is More handy Beacuse of some additionally nice methods Like AddRange and so.
and far most it's an array ( returns  )
but the Dictionary is restraint in method and options
I'm trying to do a very simple project where I can turn a light on and off via a software component. For example, when a mail message is received in a critical queue a light mounted on the ceiling blinks on and off in a certain pattern.
It sounds so easy but I have no idea where to start. I'm not sure how I can connect a tangible object with physical mass (Light fixture) to a logical object such as software (PC).
Can anyone recommend a kit or something like that where I could have a USB or Serial port connected to a circuit board which then in turn connects to a light switch or something to that effect?
I think codeproject has some articles on how to talk to a serial port in c#.
Since most PCs nowadays don't have a parallel port any more, it may be useful to know
you can do similar things with a serial port; on a typical DB9 connector there are
some 5 so called control lines; some are inputs to the PC, others are outputs.
And you can observe the inputs and control the outputs using the SerialPort class,
once you have opened the appropriate port.
You will find several relevant articles on CP about this.
BTW: if you are not really familiar with electronics, I strongly recommend you
experiment with a USB-to-serial cable; that way, when you damage the goods, it is
just that cable that has to be replaced, not your I/O card or mother board.
Ah.. great advise. Any chance there is an aftermarket kit that I could purchase on the hardware side that could demonstrate how this 120v lamp connects to a circuit board and then from the circuit board to the serial/parallel/usb port on the PC?
For USB based control and measurement of external devices I'm a big fan of the miniLAB 1008[^]
2 10 bit analog outputs
4 12 bit analog inputs or 8 11 bit single ended
Slight overkill for just turning one device on and off (for which you would need to use the miniLAB to switch a relay), but should you progress to analog contol and measurement or decide to control several devices it's pretty cheap and very easy to set up and use.
No doubt there are loads of other similar bits of kit - I've just had a lot of success with these.
I have a weird problem. I'm using 2 applications (Client and Server). Both are connected using remoting. Somehow, I got a problem, if I say connect to server, I got an exception :
"The input stream is not a valid format. 3C-22-....".. something like that.
(I'm using username : userA)
BUT, if I logout from windows and login again using another username (userB), it works.
Both users are Administrator.
If I delete userA, then create it again, it works....
Does anybody knows, what's wrong with remoting or user problem ??
Last Visit: 25-Feb-20 1:44 Last Update: 25-Feb-20 1:44