|
Hi,
PORT NAMES
I guess your COM3 is a real serial port that is inaccessible because it is used for
an internal modem, so it would show up elsewhere in Device Manager (try modems),
but technically it still is a serial port, so yes FetPortNames() would show it,
as it also shows serial ports that are already in use.
A terminal emulator, or some other program, may prefer to only show available ports,
hence it would enumerate SerialPort.GetPortNames and test them for availability
(probably SerialPort.IsOpen does exactly that).
SERIAL OUTPUT
The serial output is buffered, similar to serial input. So each write adds data to the
output buffer, unless the buffer is full. The buffer gets emptied automatically towards
the serial cable (and its attached device), but this may fail when some kind of dataflow
has been specified and is currently in HOLD (as in: software dataflow and CTRL/S received,
or hardware dataflow and the appropriate control input pin asserted, I believe it is
DSR, readable through SerialPort.DsrHolding ).
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hi, i have several textBoxes on a form and i want to set a Boolean to false if a key is pressed in any of them.
Is there a quick method to do that instead of "textBox1_KeyPress", "textBox2_KeyPress" ect... ?
Thanks in advance
|
|
|
|
|
You can have one KeyPress event handler for all of the textboxes
|
|
|
|
|
or you may set Form.KeyPreview true and take care of it in Form.OnKeyDown/OnKeyPress
(possibly with checking object sender is a TextBox).
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Luc Pattyn wrote: or you may set Form.KeyPreview true and take care of it in Form.OnKeyDown/OnKeyPress
(possibly with checking object sender is a TextBox).
Thx allot it works.
I am also interested in Giorgi solution as i do not know how to do what he tells.
|
|
|
|
|
If you are using Visual Studio then select the button you want to set event handler for and switch to the event list in properties window. Find the KeyPress event there and choose the event handler you want to attach from the drop-down list. For each button select the same event.
|
|
|
|
|
I am sorry if I am sounding dumb. I want to use treeview control to display certain text of object and perform certain action by fetching values of the object on selection.
Suppose I have an Employee Class which have getters setters like Name,AGE, DOJ etc. What I want to show name of employee as treenode text and then upon selection wants to execute getters like DOJ,AGE etc to fetch other values of that employee object. Tree Structure could be something like:
Engineer Dept
|_ Employee1
|_ Employee2
Finance Dept
|_ Employee3
|_ Employee4
I am not being able to figure out how to that. I can loop thru object by calling some getName() to extract the Name but not successful to fetch other values. Do I write some search function which will check required 'Keyword' by going thru all Objects and then return an OBJECT to perform task?
pls help me out
|
|
|
|
|
What about using "tag"??
e.g:
<br />
myNode.value = objEmployee.Name;<br />
myNode.tag = objEmployee;<br />
<br />
Treeview.Nodes.Add(myNode);
There is a property called "tag" in each node.. so, you can use it for storing the object...
|
|
|
|
|
Michael's solution is what your looking for.
You could improve it slightly by overriding the ToString method in the Employee class to return the Name property, so myNode.Text = objEmployee.ToString();
The benefit of this is you can manipulate the data to be displayed within the class itself. Also, if you later need to add this data to a combo box or similar, these controls automatically use this method to determine what data to display (the Items collection is a collection of objects not strings).
I'm not sure why Microsoft didn't include a treeview.Nodes.Add(object item)
|
|
|
|
|
DaveyM69 wrote: I'm not sure why Microsoft didn't include a treeview.Nodes.Add(object item)
act, i typed just like that.. so.. I hope he might get some ideas at least..
DaveyM69 wrote: You could improve it slightly by overriding the ToString method in the Employee class to return the Name property, so myNode.Text = objEmployee.ToString();
yeah.. that's good idea.
|
|
|
|
|
Hi all
I am new to C#, we are developing an application and it must support many languages including Asian and arabic. the problem is in some cultures like Arabic, the control's position is different, apart from that, there are lots of labels and buttons in this application so how can we managed all these labels to automatically change their values and positions?
I managed to define resources and assembly but in this case I have to choose label by calling some methods to retrieve the correct label for current culture and this seems really hard and very untidy code. is there a way to define resource for each form so it automatically will be used when the culture changed
any suggestion would be of great help
thank you very much
|
|
|
|
|
Set the localizable property of form to true and design the form for different languages by setting the language property.
|
|
|
|
|
thanks yes it's working
but another question is how do you usually do this? I mean, consider we designed a form with default language now we keep the resx file somewhere and then we change the language and design new interface and then create new resx file, is this right?
|
|
|
|
|
Yes, that is right. During runtime you can set the UI culture by setting the CurrentThread.CurrentUICulture property and the resources for that language will be loaded
|
|
|
|
|
I have to mail a file as attachment which is on other server
How to access that file
Gaurav
|
|
|
|
|
you could try using the UNC path to the file in the attach file box \\Servername\share\folder\filename
|
|
|
|
|
i am new to this forum. i am unable to search the topics in C# discussions. how to search the topics?
actually i searched for constructor topics in C# discussion. the way i searched is
search comments -> "constructor" in keyword box.
but i didnt find.
|
|
|
|
|
Searching has some problems here..
What is your question??
|
|
|
|
|
I am adding a help menu with an about menu item.
I want to have a form open here.
I tried to add a form in the solution explorer but was unable to get it to open.
How could I make a form open in the Click event in a menu item?
|
|
|
|
|
After adding new form ( let's say "Form1"), you can write the following code in menu_click event..
Form1 f1 = new Form1();<br />
f1.ShowDialog();
|
|
|
|
|
Thanks
It works great now
|
|
|
|
|
I need to convert an INT to Hex in my C# code.
Visual Basic had this Converter Class with functions like that. Is there something comparable in .Net or C#?
|
|
|
|
|
hi,
int.ToString("X"); or int.ToString("X8"); or ...
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Thanks.
Luc, your answers are always quick but often not very deep or specific... and many times, they are downright glib. For instance, it's not very clear to me what "X" and "X8" are (I'm looking at ToString() now in the documentation, but you could have been much more helpful in identifying whether these were format providers, etc).
Take a look at the answers that are rated very highly in these forums. They are informative, sometimes deep. They can be very useful and educational without necessarily being deep or long.
This, of course, is just my opinion. It's nice to have a quick pointer come up immediately, but in all of the questions I've asked that you've answered (and you've answered them all ), yours is rarely the most useful answer.
It's good to know, though, that you are available in late hours
|
|
|
|
|
I am providing pointers and encouraging people to read the documentation, that is the
way to learn and become a professional. IMO spoon feeding is not that helpful.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|