All good advice. Thanks for your time luc! :-D
TheTinSoldier
Posts
-
Using Using object disposal... -
Using Using object disposal...That makes it clear! Thanks! :cool:
-
Using Using object disposal...Good to know! Thanks!
-
Using Using object disposal...Hi Luc. In regards to your points: 1. I need to first open the port to call the IsOpen property. I am checking if the port is in use. (not by my application). 2. It would be nice to know if it does matter, as I'll do it your way if it's the right way 3. I get the feeling (from you and others) that even though the object will be disposed it wouldn't hurt to close it first. 4. This is interesting, I'd better check that out. I think for what I'm doing it should be ok. Thanks to you and everyone for their help!
-
Using Using object disposal...Thanks for your reply. I was pretty sure that was right. :-D Hey, but if an object doesn't implement IDisposable is there any point in using Using?
-
Using Using object disposal...Cheers! :-D
-
Using Using object disposal...Thanks for your reply. So what I'm doing is ok? i.e the serial port will be disposed in all cases when it leaves the using scope?
-
DataGridView && ErrorProviderUse the ErrorText property:
private void dgv_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) { DataGridView dgv = sender as DataGridView; if (dgv.IsCurrentCellInEditMode) { dgv.Rows[e.RowIndex].ErrorText = "You made an error"; } }
-
Populating data in a formAdd a Column/Link button to the row, handle the cell content click event and pass a reference to the row data to the new form:
private void dgv_CellContentClick(object sender, DataGridViewCellEventArgs e) { DataGridView dgv = sender as DataGridView; if (dgv.Columns[e.ColumnIndex] is DataGridViewButtonColumn) { DataForm df = new DataForm(dgv.Rows[e.RowIndex]); df.ShowDialog(); } }
I think that should do it! -- modified at 17:33 Wednesday 18th July, 2007
-
Using Using object disposal...Check this code. Two questions: 1. After opening the serial port do I need to worry about closing the port as when I return (leave the using scope) the object will automatically be disposed? 2. If the code enters the catch block will the serial port object automatically be disposed after leaving the using scope? Thanks!
public static bool IsPortInUse(string portName) { try { using(SerialPort sp = new SerialPort(portName)) { sp.Open(); return false; } } catch (UnauthorizedAccessException e) { return true; } }
-
Updating UI/Dataset from serialportNow that sounds like fun! I was talking to my brother over the weekend about shooting guns and I must admit that I reakon is would be a real blast - pun intended. I've shot a .22 and a slug gun when I was a kid but that's about it. I've still to check off the shotgun! It's got to be on the list of things to do at least once! Well anyway Ed, good luck and bring back some silverware!:cool:
-
Updating UI/Dataset from serialportOoops well, I guess I didn't update the default profile. I'm actually from NZ and live in NZ! So, we will have to have that beer another time! Shooting eh??! World champs! I guess you are competing, well if you dead eye with the pistola as you are with code you're bound to do well! Thanks again for you help, I really appreciated the time you spent. Good luck!
-
Updating UI/Dataset from serialportHoly Bible Batman you're right!!!! Arrgggh! I didn't test your code but just tried it on my own and it works... thanks to you and your tenacious approach. And not one delegate or generic in sight! My workmate says that if your over our neck of the woods sometime (NZ) we owe you a beer. Thanks very much Ed, you've been a real help on a prob that had me completely stumped. :cool:
-
Updating UI/Dataset from serialport- I didn't change the code in the buttons event handler. - I scrapped the wrapper method. - The handler is firing ok, and I've stepped through the
ChangeValue
method, it's doing what it should - that is, it's changing the value in the dataset. I know this because whether theDataReceived
event handler or thebutton
event callsChangeValue
the value changes and I can see it as I step though that it's been changed from the previous value. What's not updating is the Text property of the Label control that the Dataset is bound to. P.S If I trigger theChangeValue
method via the button first, the label updates fine. But if I triggerChangeValue
via your delegate method and then try the button the label doesn't update. -
Updating UI/Dataset from serialportDang, didn't work. Does the block:
// Invoke delegate normally singleCastDelegate.DynamicInvoke(arguments);
Mean that it's not cross threaded? Curiously though, after I use your class then click on the button to change the value (just to see if it still works) it doesn't update the value in the label anymore... P.S I had to put a check in your code as I was getting an errorif (arguments != null) <- here { if (requiredParameters != arguments.Length) .... }
-
Updating UI/Dataset from serialportI have an error when I compile. This is the code I updated:
private void _sp_DataReceived(object sender, SerialDataReceivedEventArgs e) { // run this method when the event fires InvocationHelper.Invoke(this.ChangeValue); }
Argument '1': cannot convert from 'method group' to 'System.Delegate' P.S If you prefer to have a fiddle yourself I can send you the source. Thanks for being so helpful. -
Updating UI/Dataset from serialportGreat info about the exception I'll give it a crack now, and check out your helper class. Super! :-D
-
Updating UI/Dataset from serialportThanks again Ed! I've just arrived and work this morning and it's great to see your message. Well, although I'm new to generics, I am actually using them in my project already. I'm sure I'll use them more and more as they do seem well suited to many situations, I'm just getting to the 'once you know how part'. The word delegate makes me nervous, but I'll put it with the 'once you know how' and I'm sure I'll get the hang of it. Hey, your source has been blocked, could you zip it please? Thanks heaps, you've been great. Oh, I forgot to say that under the Debug -> Exceptions, are you refering to the 'thrown' check box or the 'user-handled' check box associated with the CLR Exceptions tree? -- modified at 15:05 Wednesday 14th February, 2007
-
Updating UI/Dataset from serialportThanks Ed! Actually I saw you article today when I was searching for help. You are right it's not a form. I scanned over your article but it seemed quite complex to me (I still haven't really got my head around delegates or generics) but I'm fast running out of options so I'm going to study it and hopefully I'll find the answer.
-
Updating UI/Dataset from serialportthere is no this.invoke() ??!