Page 1 of 1

inserting tabs programmatically

Posted: Mon Feb 26, 2007 1:18 pm
by PKH
I am trying to create a report containing a statistical analysis. How can I programmatically (i.e., use code) insert tabs so that the output lines up vertically. For example:

Code: Select all

mean:      3.4     95%LCL = 2.0     95%UCL = 5.0
sd:        1.5     95%LCL = 0.5     95%UCL = 2.3
Paul

Posted: Tue Feb 27, 2007 11:27 am
by Sergey Tkachenko
Use paragraph style with assigned Tab property, and #9 character in text.
For example:

Code: Select all

var ParaNo: Integer;
begin
  with  RVStyle1.ParaStyles.Add do begin
    Tabs.Add.Position := 50;
    Tabs.Add.Position := 90;
    Tabs.Add.Position := 150;
    Options := [rvpaoNoWrap]
  end;
  ParaNo := RVStyle1.ParaStyles.Count-1;
  RichView1.AddTextNL(
    'mean:'#9'3.4'#9'95%LCL = 2.0'#9'95%UCL = 5.0'#13#10+
    'sd:'#9'1.5'#9'95%LCL = 0.5'#9'95%UCL = 2.3', 0, ParaNo, ParaNo);
  RichView1.Format;
end;
But I recommend using tables instead of tabs when possible. They are more easy to modify. And HTML does not support tabs.

Posted: Tue Feb 27, 2007 6:34 pm
by PKH
Your did code not work for me, but it put me on the right track. Below is your code modified to do exactly what I wanted. I found that I had to set the number of tab spaces to 0 for this to work. I pass to this procedure the name of the statistic, its value (as a string), and its lower and upper confidence limits (as strings). They are then printed exactly as I wanted. Your RichView component is great, but figuring out how to make it do what I want can be frustrating. Thanks for your help.

Paul

PROCEDURE ADD_RESULTS(stat,value,LCL,UCL:string);
var ParaNo: Integer;
BEGIN
RVStyle1.ParaStyles.Add.Options := [rvpaoNoWrap];
ParaNo := RVStyle1.ParaStyles.Count-1;
rve.AddTextNL( stat + #09 + value +#09+#09 + LCL +
#09+#09 + UCL , 0 , ParaNo , ParaNo);
rve.Format;
END;

Posted: Wed Feb 28, 2007 9:20 am
by Sergey Tkachenko
Default value of RVStyle.SpacesInTab is 0, since the time when tab stops (RVStyle.ParaStyles[].Tabs) were implemented.
Probably you created your project several years ago, and it was started with older version of TRichView.