Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1209
  • Last Modified:

multiline textbox with scrollbars on demand

I'm trying to find a way to dynamically change a textbox control array so that some textboxes are multiline with scrollbars and some are single-line without scrollbars.

Since the Multiline property cannot be changed at run-time, I simply disable the Enter key for single-line mode.

Now I realized that I may need to allow more lines than the display supports and would like to add vertical scroll bars only in multiline mode.

Since scrollbars are also read-only at run-time, I can't change them.  If I have a "single-line" textbox with multiline on, the scrollbar remains but is grayed out.

Can I create a textbox that lets me dynamically change between single-line and multi-line, and only shows scrollbars in multi-line mode.

...or is there another control that supports this?

...or maybe I should simply spend a few weeks writing my own???
0
rspahitz
Asked:
rspahitz
  • 6
  • 5
  • 3
  • +1
1 Solution
 
Anthony PerkinsCommented:
Have you considered have two of each, making one visible and hiding the other.  Another thought, can you not create the Text Box on the fly as needed.  Lately, I don't do much forms code, so I maybe way out (not the first time, though) ...

Anthony
0
 
priya_pbkCommented:
I was just trying this workaround.

Maybe you can set the multi-line and vertical scrollbars of all the textbox which is in control array as "True". Then I think, you surely must be knowing which textbox would be single line and which would be multi-line and obvoiouly you also must be knowing the index value of the textbox array.

Check in the got focus or any any other appropriate event of the textbox by checking the index value of the textbox.
Say for eg:

txtArray(0) will be holding name of a person
txtArray(1) will be holding the corresponding address, which got to be multi-line

Therefore you can do it this way:
1)If the index value is 0 then
-Check the length of the string, give some kind of restriction
-if the keyscii is "enter key", whatever is that, then keyascii=0
and then
textArray(0).height=495
textArray(1).Width = 2925

2) then check if the index value is 1
if it is so then
-no restriction of any kind
TextArray(1).Height = 5095
TextArray(1).Width = 2925

This is just a logic i was thinking of, and not tested or tried out. Hope this info helps

-priya

0
 
Richie_SimonettiIT OperationsCommented:
besides Acperkins's comment, the only way that i know to achieve it is using controls created by your own with API.
If you are interested:
http://www.vbaccelerator.com/codelib/submit/txtboxex.htm
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Richie_SimonettiIT OperationsCommented:
0
 
rspahitzAuthor Commented:
Adding an extra textbox might be okay, but at this point it becomes a lot of extra overhead.  The reason is that I'm already putting the textbox, a combobox, several labels, and several other controls into a user-control called a Multi-Input control.  By changing various properties, it switches between combobox, textbox, and option buttons in the future.  To add an extra textbox simply to allow scrollbars is, in my opinion, too much.

As for the links, the first one is asking for trouble in my multi-developer environment.  We've already dealt with the headaches of special controls needing to be registered for development.  The second one is so many APIs that I'm concerned that they won't port well to .NET when we go there next year.

If there is a simple, single API (or two) to enable/disable the scrollbars, I'll use it; otherwise I may simply choose to not use the scrollbars at all and leave the project as it is.
0
 
Richie_SimonettiIT OperationsCommented:
Regarding second link (i suposse you are talking about my comment :) is the minimun usage to create windows like an Oldie C++ program has been doing (before classes).
It could be wrapped to create controls with properties like VB has.
Almost every window in this OS are using them.
Cheers
0
 
rspahitzAuthor Commented:
Yes, Richie.
If I wrap all that then will it be compatible with .NET?  I don't want to risk building something with all that only to throw it away in a few months.

I was really hoping for a much simpler solution, like "API to hide textbox scrollbars: xxx"

0
 
Anthony PerkinsCommented:
rspahitz,

Let's be candid:  If you are planning to migrate your VB6 code to VB.NET, you may want to think again.  Quite frankly, unless it is a trivial app, this is not doable.

Anthony
0
 
Richie_SimonettiIT OperationsCommented:
Hats off for Tony!!
0
 
Anthony PerkinsCommented:
Richie,

Your check is in the mail! <g>

Anthony
0
 
Richie_SimonettiIT OperationsCommented:
<offtopic>
No. For past things, YOUR check is in the mail :)
Como salimos hoy?
</offtopic>
0
 
rspahitzAuthor Commented:
Well, it's not so much that we are PLANNING to migrate to .net but rather that it seems to be the inevitable migration path.  As I built this app, I went out of my way to limit the potential for problem in migrating (based on research of what .net offers.)

Since this app will be around for many more years, and will likely go through many more changes, I don't want to add more levels of complexity that will make it a huge migration effort (i.e. K.I.S.S.!)...especially for such a small issue as a missing scrollbar.

I'll give this a few more days to see if anyone else comes in with other suggestions on how to approach this.  If not, I'll decide which comment would be best if I were to actually do the implementation.
0
 
Richie_SimonettiIT OperationsCommented:
As you surely know and for the record, you don't need to use the complete control but just those part of code that meets your requirements.
0
 
rspahitzAuthor Commented:
I'm accepting this because it is the simplest solution, although still not what I really wanted.

I dropped the same question on carobit.com and was told that I could use the RichTextBox, which hides the scroll bar when not needed.  (Tested and confirmed.) I like that idea, but I think the overhead of RTB is greater than another textbox(!), not to mention that there's another component to deliver.

At this point, I've decided to simply ignore the problem and wait until a real user complains.  Snice I was told that this will probably not go into production until the end of the year, I'll be able to better evaluate whether we plan to migrate it to .net or leave it in VB6.  If .net offers better support for the textboxes, then problem will be solved at that point anyway.

Thanks all.
0
 
rspahitzAuthor Commented:
Oops...forgot to accept the comment...
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 6
  • 5
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now