VB给的TextBox和RichText 都不能控制文本的行间距,谁有,介绍给我,高分相送。

解决方案 »

  1.   

    RichTextBox 应该可以吧,设置一些字符的属性。
      

  2.   

    RichTextBox 可以 :Option ExplicitPrivate Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As LongConst WM_USER = &H400
    Const PFM_LINESPACING = &H100
    Const MAX_TAB_STOPS = 32
    Const EM_SETPARAFORMAT = WM_USER + 71Private Type PARAFORMAT2
        cbSize As Integer
        wPad1 As Integer
        dwMask As Long
        wNumbering As Integer
        wReserved As Integer
        dxStartIndent As Long
        dxRightIndent As Long
        dxOffset As Long
        wAlignment As Integer
        cTabCount As Integer
        lTabStops(0 To MAX_TAB_STOPS - 1) As Long
        dySpaceBefore As Long          ' /* Vertical spacing before para         */
        dySpaceAfter As Long           ' /* Vertical spacing after para          */
        dyLineSpacing As Long          ' /* Line spacing depending on Rule       */
        sStyle As Integer                  ' /* Style handle
        bLineSpacingRule As Byte       ' /* Rule for line spacing (see tom.doc)  */
        bCRC As Byte                   ' /* Reserved for CRC for rapid searching *
        wShadingWeight As Integer          ' /* Shading in hundredths of a per cent
        wShadingStyle As Integer           ' /* Nibble 0: style, 1: cfpat, 2: cbpat
        wNumberingStart As Integer         ' /* Starting value for numbering
        wNumberingStyle As Integer        ' /* Alignment, roman/arabic, (), ), .,
        wNumberingTab As Integer           ' /* Space bet 1st indent and 1st-line
        wBorderSpace As Integer            ' /* Space between border and text
        wBorderWidth As Integer           ' /* Border pen width (twips)
        wBorders As Integer                ' /* Byte 0: bits specify which borders
    End TypePrivate Sub Command1_Click()
        Dim x As PARAFORMAT2
        
        RichTextBox1.SelStart = 0
        RichTextBox1.SelLength = Len(RichTextBox1.Text)
      
        x.cbSize = Len(x)
        x.dwMask = PFM_LINESPACING
        x.bLineSpacingRule = 5
        x.dyLineSpacing = 60
        Call SendMessage(RichTextBox1.hwnd, EM_SETPARAFORMAT, 0, x)
    End SubPrivate Sub Form_Load()
        RichTextBox1.Text = RichTextBox1.Text + vbCrLf
        RichTextBox1.Text = RichTextBox1.Text + "AAAAAAAAAAAAAAAA"
        RichTextBox1.Text = RichTextBox1.Text + vbCrLf
        RichTextBox1.Text = RichTextBox1.Text + "BBBBBBBBBBBBBBBBBb"
        RichTextBox1.Text = RichTextBox1.Text + vbCrLf
        RichTextBox1.Text = RichTextBox1.Text + "CCCCCCCCCCCCCCCCCCcc"
    End Sub
    上面的代码点击Command1设置RichTextBox1的行间距
      

  3.   

    要用到API,太麻烦了,有现成的控件吗?
      

  4.   

    有,但是是收费的
    ALLText HT/Pro(http://www.bennet-tec.com)或TX Text Control(http://www.textcontrol.com/)