Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Button inside multiline TextBox in VB?
 

Button inside multiline TextBox in VB?

How can I insert button inside multiline TextBox ?

I want button should be on top of Vertical scroll of multiline TextBox.

I am thankful if any one resolve this problem.
Manohar Rudra  Tuesday, April 28, 2009 4:44 AM

Hi Manohar Rudra,

You can put a button on any part of a multiline text. I don't know what problem you are facing now. Does that make sense to put a button to cover the vertical scroll bar?

Sincerely,
Kira Qian


Please mark the replies as answers if they help and unmark if they don't.
Kira Qian  Thursday, April 30, 2009 2:43 AM

We are changing the issue type to “General Discussion�because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question�by opening the Options list at the top of the post editor window, and changing the type. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions.


Please mark the replies as answers if they help and unmark if they don't.
Kira Qian  Monday, May 04, 2009 5:11 AM

Hi Kira Qian,

If I set property Scrollbar to Vertical on multiline TextBox,I cant insert button on Verical scrollbar.

My basic requirment is to develop an Active X control to edit text in multiline TextBox. For thatone I need a multiline TextBox, Vertical scrollbar and a Button. When User click on theButton, one form will be open .

User canedit text on the form. If he click Ok button onthe form , changes will be reflected to multiline textbox. If he clickCancel on the Form changes will not be reflected to multiline TextBox.

Here is the Code for Usercontrol:-

Private oForm As Form1
Private lineCount As Integer
Private MaxLineCount As Integer
Private Sub Command1_Click()
oForm.Text2.Text = Text1.Text
oForm.strText = Text1.Text
oForm.Show vbModal
Text1.Text = oForm.Text2.Text
End Sub

Private Sub Text1_Change()
lineCount = Len(Text1.Text) - Len(Replace(Text1.Text, vbCrLf, vbCr))
If lineCount - MaxLineCount > 0 Then
VScroll1.Enabled = True
Else
VScroll1.Enabled = False
End If
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
If (Text1.SelStart < VScroll1.Max) And VScroll1.Enabled = True Then
VScroll1.Value = Text1.SelStart
End If
End Sub

Private Sub UserControl_Initialize()
VScroll1.Max = (VScroll1.Height - Text1.Height) + 1000
VScroll1.SmallChange = 50
VScroll1.LargeChange = 100
MaxLineCount = 2
VScroll1.Enabled = False
Set oForm = New Form1
End Sub

Private Sub UserControl_Terminate()
Set oForm = Nothing
End Sub


Private Sub VScroll1_Change()
Text1.SelStart = VScroll1.Value
End Sub

Private Sub VScroll1_Scroll()
'Text1.SelStart = VScroll1.Value
End Sub

Here is the Codefor Form:-

Public strText As String

Private Sub Cancel_Click()
Text2.Text = strText
Me.Hide
End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 27 Then
Call Cancel_Click
End If
End Sub


Private Sub OK_Click()
Me.Hide
End Sub

Private Sub Text2_GotFocus()
strText = Text2.Text
End Sub

Here implementation for Vscroll is not proper. Could you please help me to implement Vertical Scroll functionality.Remember that I amusing seperate Vertical Scroolbar to scroll the text.

Please help me if you know the functionality of Vertical Scrollbar.

Thanks
Manohar Rudra



Manohar Rudra  Tuesday, May 05, 2009 11:00 AM

You can use google to search for other answers

Custom Search

More Threads

• Controls change position when form is opened in designer
• Control Overlap (weird!)
• How to allow resizing in one direction only?
• How to make a Picturebox accept focus
• TypeDescriptor.GetProperties and ExtenderProviders
• Adding the Cut/Copy/Paste in a class that implements IMenuCommandService
• Custom user controls will not show up automatically on toolbox
• showing details in tree and editing it in windows form-very very urgent
• How can Restrict a model form or Dialog form in ClientRectangle of MDI form.
• Controls arrays