Solved

multiline textbox with scrollbars on demand

Posted on 2002-06-05
15
1,157 Views
Last Modified: 2011-04-14
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
Comment
Question by:rspahitz
  • 6
  • 5
  • 3
  • +1
15 Comments
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 100 total points
ID: 7058066
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
 
LVL 2

Expert Comment

by:priya_pbk
ID: 7058860
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7059410
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7059418
0
 
LVL 22

Author Comment

by:rspahitz
ID: 7059810
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7060108
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
 
LVL 22

Author Comment

by:rspahitz
ID: 7060143
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 7060154
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7060218
Hats off for Tony!!
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 7060221
Richie,

Your check is in the mail! <g>

Anthony
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7060270
<offtopic>
No. For past things, YOUR check is in the mail :)
Como salimos hoy?
</offtopic>
0
 
LVL 22

Author Comment

by:rspahitz
ID: 7060300
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7063840
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
 
LVL 22

Author Comment

by:rspahitz
ID: 7067696
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
 
LVL 22

Author Comment

by:rspahitz
ID: 7149626
Oops...forgot to accept the comment...
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now