Posted 4 August 2017, 3:18 pm ESTHello,
I will try and explain my problem the best way I can.
We're developing a report system that allows users to select which fields (from recordset) they want to show in their report.
We load Field names from the recordset into ListView1 and then the user select the fields he/she wants to display and transfers them to ListView2.
The report is created dynamically, and depending on how many fields the user has selected we create Labels and TextBoxes.
So, the first label is created at .Left = 0 and its width is calculated like: TextWidth(ListView2.ListItems.ListViewItem.Text)
After that, we create the first TextBox and set it's .Left = 0 and width is calculated like : TextWidth(recordset.Fields(recordposition).Value)
After this we create all the other labels and fields.
We check to see if the FIRST label width > FIRST field width...If this is TRUE then the second label .Left will be: FirstLabel.Left + FirstLabelWidth.If the FirstLabelWidth < FirstFieldWidth then SecondLabel.Left = FirstTextLeft + FirstTextWidth
Now this works fine if we have a case where the first 3 or 4 values added from the recordset to the field have the same width.But what happens if the FIFTH value is much wider then the previous 4?Then the next Label will not start from the correct left position and also,there will be some overlapping of the TextBox controls.
Basically, we're trying to find a way to set up the Width and the Left position of the controls AFTER everything has been added to the report.I know we can use WithEvents to access Details_Format sub and others, but not sure if that is the right way to go.
Any suggestions will be appreciated