Question Creating editable text on a form.

bobrocks

New member
Joined
Jun 2, 2009
Messages
1
Programming Experience
5-10
Hello all,

I am using VS2008, I need to update a vb6 application that I wrote a while back and make it more user friendly. [EDIT] I am not using any of the vb6 code, this is a complete rewrite.[/EDIT] The application basically creates ZPL based on user inputs, it sends the ZPL to the printer via the parallel port and we have our label. I know there are pre-written pieces of software that do this but I have a few other things going on that are not an option for a pre-written label application.

The task at hand at this point is creating a form which will display a mock-up of the label and allow the user to create text, rotate it, move it, re-size it etc. I will also have to add in image support a little further down the line but I figured i would keep it simple to start out. This is my first major project in .net (the company has been hesitant to spend the money until now and I haven't had the time to do much on my own.)

I think the best place for me to start would be with a simple form with a button that allows me to create text and edit it only. I am unsure of the best way to pull this off, should I be using a label, a text box with the design styles turned off or something altogether different that I may not know about?

To summarize:

a) What type of object should I be using?
b) How would I go about creating it?
c) How should I go about making it movable/editable at runtime?

As an aside, I am aware that the ThermalLabel SDK would probably be beneficial in this application but the company is not willing to spend anymore on this project. (Trust me, I know what you are thinking.)

Thanks in advance for any help!

-Bob
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,335
Location
Sydney, Australia
Programming Experience
10+
I think you're going to need to use GDI+ for this. GDI+ allows you to draw basically whatever you want, however you want, wherever you want. You can draw text, lines, shapes, colours and images in any position and orientation directly onto the form or some other control. The problem is that there are no visual objects involved, so there's no editable text or draggable boxes or the like. It's easy enough to do something like provide a TextBox elsewhere and then you update the drawing as the user edits the text, but allowing the user edit in-place or drag drawn objects around, while possible, is not very easy. It's one of those situations where the simpler you want to make things for the user, the more complex the code becomes.

You may also find that creating this kind of interface is easier in WPF than in Windows Forms.
 

InertiaM

Well-known member
Joined
Nov 3, 2007
Messages
663
Location
Kent, UK
Programming Experience
10+
As jmcilhinney said, I would personally forget trying to do the in-place editing.

I would probably design the form with SplitContainers, and then adjust the upper right based on the type of element (text, barcode, rectangle etc etc). The bottom right would be drawn with GDI+, and you could colour the active element differently (eg highlight in red etc).

I've thrown together an example for you :)
 

Attachments

  • ZPL.jpg
    ZPL.jpg
    27.4 KB · Views: 25
Top Bottom