Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I'm developing an Winform GUI Application, that uses the serial port to communicate with a sensor. Everytime I send a request, it sends me a response, like this:

Request: readBasicAttr 0
readColorControl 0

I receive response like this:

Attr 0x0000= 1
Attr 0x0000= 123

Now I want to put each response in a textbox, but i don't know how to do this. Basically I want to put the first response to textbox 1, the second to textbox 2 etc...

Does anyone have experience with this? No need to write the code for me, just tell me how to do this, and I'll write the code myself

Best regards
Posted

I would strongly suggest that a textbox each is a bad idea - it's perfectly feasible, but it's clumsy, both to implement and for the user.

Have you considered using a DataGridView or a ListBox instead? Both of them are a lot more flexible than separate textboxes.
 
Share this answer
 
OriginalGriff is right... what you are suggesting can be done better. But... maybe you have a good reason... who am I to judge?

So if you have them in a groupbox or some other container like that, you can iterate the child controls array (it is a property on that containing control) to get a reference to each control within the container. Order isn't guaranteed although they will typically appear in the order they were added to the container. But, giving the text boxes sequential names like "databoxXX" where XX is an increasing number would allow you to reference them by name. A simple counter can be incremented to generate the next name.


Good luck.
 
Share this answer
 
Comments
Member 11549235 24-Apr-15 3:37am    
Hi guys,

Thanks for the comments. I really need to show these informations in textboxes, in order to show the user, which one is basic attribute and which one is color control. I have just tried to add all the received datas from serial port to an ArrayList, and then I will access to it to retrieve the information I need. the order of datas seem to be constant, but I'll give it more test, in order to be sure. It's not elegant, but I think this would work.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900