473,385 Members | 1,564 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Dynamically placed text boxes

Hello,

Is there a way to have textbox placement be dynamic depending on the visibility of another textbox? For example, I'm creating a form where people enter time. There's a field for each day of the month but I don't want to display weekend days. I also don't want a gap on the form for the days that are being hidden. I'd like to have the visible day fields all next to each other.

So basically I want to
* make a field invisible if the day of the week that it corresponds to is a Sat or Sun
* move the visible Mon-Fri fields next to each other
* Have this be dynamic as of course the calendar changes each month.

Any ideas out there would be appreciated.

Thanks!
Jun 16 '08 #1
1 4575
ADezii
8,834 Expert 8TB
You can dynamically and precisely position Text Boxes on a Form by manipulating their Left, Top, Width, and Height Properties. In the sample code I created, 4 Text Boxes (txtBox1, txtBox2, txtBox3, and txtBox4), three of which are dynamically and precisely positioned below txtBox1. They are also aligned Left with txtBox1, and all have a 1/8" Spaced between them vertically. It would only be a simple matter to create the logic which would now control their positioning. Be advised that the newly created positions of these Text Boxes will not persist and they will revert to their original positions when the Form opens again. Hope this helps.
P.S. Download the Attachment to see the simple demo that I created.
Expand|Select|Wrap|Line Numbers
  1. Dim T1 As TextBox
  2. Dim T2 As TextBox
  3. Dim T3 As TextBox
  4. Dim T4 As TextBox
  5. Const conSpacerInTwips As Integer = 180
  6.  
  7. Set T1 = Me![txtBox1]
  8. Set T2 = Me![txtBox2]
  9. Set T3 = Me![txtBox3]
  10. Set T4 = Me![txtBox4]
  11.  
  12. 'Position txtBox2 below txtBox1, aligned Left with 1/8" Spacer
  13. T2.Left = T1.Left
  14. T2.Top = T1.Top + T1.Height + conSpacerInTwips
  15.  
  16. 'Position txtBox3 below txtBox2, aligned Left with 1/8" Spacer
  17. T3.Left = T1.Left
  18. T3.Top = T2.Top + T2.Height + conSpacerInTwips
  19.  
  20. 'Position txtBox4 below txtBox3, aligned Left with 1/8" Spacer
  21. T4.Left = T1.Left
  22. T4.Top = T3.Top + T3.Height + conSpacerInTwips
Jun 17 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Vince C. | last post by:
Hi all, I've created XML documents that are described with a schema. I'm using those documents to create web pages. All my web pages contain a fixed header and a variable document part. The...
8
by: Donald Xie | last post by:
Hi, I noticed an interesting effect when working with controls that are dynamically loaded. For instance, on a web form with a PlaceHolder control named ImageHolder, I dynamically add an image...
1
by: Daniel Gormley | last post by:
What I have is a form that is dynamically generated based on which database table its calling. Therefore, the number of category.name.count can be different. So I have this form generated and...
2
by: Sethos | last post by:
I am sure that this has been covered, hashed, and rehashed, but a search on the group did not produce the answer, so forgive me if this seems like a "newbie" type question... Besically, I have a...
5
by: tarscher | last post by:
Hi all, I create a set of text-boxes based on user input: for (int i = 0; i < Convert.ToInt16(keywordsDropDownList.Text); i++) { myTextBox = new TextBox(); myTextBox.Columns = 5;...
0
by: Jeff User | last post by:
Hi all I need to create datagris dynamically in C# code. I placed a PlaceHolder object on my form and then as Datagrids are created, they are added to the PlaceHolder. This works and display well...
8
by: BillE | last post by:
When I create a control dynamically and it grows according to the content, the control Height property still returns the original default control height instead of the height after expanding. ...
1
by: lxyone | last post by:
Using a flat file containing table names, fields, values whats the best way of creating forms / html pages? I want control over the html pages ie 1. layout 2. what data to show 3. what...
1
by: semomaniz | last post by:
I have a form where i have created the form dynamically. First i manually added a panel control to the web page. Then i added another panel dynamically and inside this panel i created tables. I have...
2
by: gubbachchi | last post by:
Hi, I have a form whose elements are created dynamically on selection, i.e. the form has only text boxes and the number of text boxes depends on the users selection, if user selects 3 then 3...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.