Hey hi! all
Is it possible to implement block selection (Like available with ms word hold down alt key and drag mouse arrow) this will select specific area and text under that region. this feature is also available with vs IDE.
Any one having any idea regarding how to do it please respond. i have posted this problem in may forums but i did not get any reply....
Thanks,
chirag
9 3213
Maybe you need to think about why noone responds... What progress have you made and what is your platform?
Maybe you need to think about why noone responds... What progress have you made and what is your platform?
its an application development (Windows.forms application) where the control on which i am trying to make this block selection available is RichTextBox control.
its an application development (Windows.forms application) where the control on which i am trying to make this block selection available is RichTextBox control.
I think Kenobewan means what code do you have, what have you tried you need to be specific. If you have code that isn't working post it.
- Imports System.Drawing
-
Imports System.Runtime.InteropServices
-
-
-
Public Class Form1
-
-
Inherits System.Windows.Forms.Form
-
-
-
#Region " Windows Form Designer generated code "
-
-
Public Sub New()
-
MyBase.New()
-
-
'This call is required by the Windows Form Designer.
-
InitializeComponent()
-
-
'Add any initialization after the InitializeComponent() call
-
-
End Sub
-
-
'Form overrides dispose to clean up the component list.
-
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
-
If disposing Then
-
If Not (components Is Nothing) Then
-
components.Dispose()
-
End If
-
End If
-
MyBase.Dispose(disposing)
-
End Sub
-
-
'Required by the Windows Form Designer
-
Private components As System.ComponentModel.IContainer
-
-
'NOTE: The following procedure is required by the Windows Form Designer
-
'It can be modified using the Windows Form Designer.
-
'Do not modify it using the code editor.
-
Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu
-
Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem
-
Friend WithEvents OpenFileMenuItem As System.Windows.Forms.MenuItem
-
Friend WithEvents CloseFileMenuItem As System.Windows.Forms.MenuItem
-
Friend WithEvents OpenFileDialog1 As System.Windows.Forms.OpenFileDialog
-
Friend WithEvents zRTB As System.Windows.Forms.RichTextBox
-
Friend WithEvents DrawingPaletteButton As System.Windows.Forms.Button
-
Friend WithEvents StatusBar1 As System.Windows.Forms.StatusBar
-
Friend WithEvents MenuItem2 As System.Windows.Forms.MenuItem
-
Friend WithEvents TransparentRichTextBox1 As RichTextboxandGDI.AlphaRichTextBox.TransparentRichTextBox
-
Friend WithEvents Label1 As System.Windows.Forms.Label
-
Friend WithEvents ShowGuidesMenuItem As System.Windows.Forms.MenuItem
-
-
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
-
Me.components = New System.ComponentModel.Container
-
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form1))
-
Me.DrawingPaletteButton = New System.Windows.Forms.Button
-
Me.zRTB = New System.Windows.Forms.RichTextBox
-
Me.MainMenu1 = New System.Windows.Forms.MainMenu(Me.components)
-
Me.MenuItem1 = New System.Windows.Forms.MenuItem
-
Me.OpenFileMenuItem = New System.Windows.Forms.MenuItem
-
Me.CloseFileMenuItem = New System.Windows.Forms.MenuItem
-
Me.MenuItem2 = New System.Windows.Forms.MenuItem
-
Me.ShowGuidesMenuItem = New System.Windows.Forms.MenuItem
-
Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog
-
Me.StatusBar1 = New System.Windows.Forms.StatusBar
-
Me.TransparentRichTextBox1 = New RichTextboxandGDI.AlphaRichTextBox.TransparentRichTextBox
-
Me.Label1 = New System.Windows.Forms.Label
-
Me.SuspendLayout()
-
'
-
'DrawingPaletteButton
-
'
-
Me.DrawingPaletteButton.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
-
Me.DrawingPaletteButton.Location = New System.Drawing.Point(704, 8)
-
Me.DrawingPaletteButton.Name = "DrawingPaletteButton"
-
Me.DrawingPaletteButton.Size = New System.Drawing.Size(104, 23)
-
Me.DrawingPaletteButton.TabIndex = 1
-
Me.DrawingPaletteButton.Text = "Drawing Palette"
-
'
-
'zRTB
-
'
-
Me.zRTB.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
-
Or System.Windows.Forms.AnchorStyles.Left) _
-
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
-
Me.zRTB.AutoWordSelection = True
-
Me.zRTB.Font = New System.Drawing.Font("Courier New", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
-
Me.zRTB.HideSelection = False
-
Me.zRTB.ImeMode = System.Windows.Forms.ImeMode.AlphaFull
-
Me.zRTB.Location = New System.Drawing.Point(0, 48)
-
Me.zRTB.Name = "zRTB"
-
Me.zRTB.ShowSelectionMargin = True
-
Me.zRTB.Size = New System.Drawing.Size(816, 279)
-
Me.zRTB.TabIndex = 2
-
Me.zRTB.Text = resources.GetString("zRTB.Text")
-
Me.zRTB.WordWrap = False
-
'
-
'MainMenu1
-
'
-
Me.MainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem1, Me.MenuItem2})
-
'
-
'MenuItem1
-
'
-
Me.MenuItem1.Index = 0
-
Me.MenuItem1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.OpenFileMenuItem, Me.CloseFileMenuItem})
-
Me.MenuItem1.Text = "File"
-
'
-
'OpenFileMenuItem
-
'
-
Me.OpenFileMenuItem.Index = 0
-
Me.OpenFileMenuItem.Text = "Open"
-
'
-
'CloseFileMenuItem
-
'
-
Me.CloseFileMenuItem.Index = 1
-
Me.CloseFileMenuItem.Text = "Close"
-
'
-
'MenuItem2
-
'
-
Me.MenuItem2.Index = 1
-
Me.MenuItem2.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.ShowGuidesMenuItem})
-
Me.MenuItem2.Text = "View"
-
'
-
'ShowGuidesMenuItem
-
'
-
Me.ShowGuidesMenuItem.Index = 0
-
Me.ShowGuidesMenuItem.Text = "Show Guides"
-
'
-
'StatusBar1
-
'
-
Me.StatusBar1.Location = New System.Drawing.Point(0, 359)
-
Me.StatusBar1.Name = "StatusBar1"
-
Me.StatusBar1.Size = New System.Drawing.Size(816, 22)
-
Me.StatusBar1.TabIndex = 3
-
'
-
'TransparentRichTextBox1
-
'
-
Me.TransparentRichTextBox1.Enabled = False
-
Me.TransparentRichTextBox1.Location = New System.Drawing.Point(8, -48)
-
Me.TransparentRichTextBox1.Name = "TransparentRichTextBox1"
-
Me.TransparentRichTextBox1.Size = New System.Drawing.Size(768, 96)
-
Me.TransparentRichTextBox1.TabIndex = 4
-
Me.TransparentRichTextBox1.Text = ""
-
'
-
'Label1
-
'
-
Me.Label1.AutoSize = True
-
Me.Label1.Location = New System.Drawing.Point(72, 336)
-
Me.Label1.Name = "Label1"
-
Me.Label1.Size = New System.Drawing.Size(39, 13)
-
Me.Label1.TabIndex = 5
-
Me.Label1.Text = "Label1"
-
'
-
'Form1
-
'
-
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
-
Me.ClientSize = New System.Drawing.Size(816, 381)
-
Me.Controls.Add(Me.Label1)
-
Me.Controls.Add(Me.TransparentRichTextBox1)
-
Me.Controls.Add(Me.StatusBar1)
-
Me.Controls.Add(Me.zRTB)
-
Me.Controls.Add(Me.DrawingPaletteButton)
-
Me.Menu = Me.MainMenu1
-
Me.Name = "Form1"
-
Me.Text = "My Editor"
-
Me.ResumeLayout(False)
-
Me.PerformLayout()
-
-
End Sub
-
-
#End Region
-
-
Dim LinePen As Pen
-
Dim LineBrush As Brush
-
Dim MeGraphics As Graphics
-
Dim XOffset As Integer = 6
-
Dim YOffset As Integer = 54
-
Dim SolidBrush As New SolidBrush(Color.Black)
-
Dim DrawBoxX, DrawBoxY As Integer
-
Dim DrawingMode As Boolean = False
-
Dim MouseDownDraw As Boolean = False
-
Dim StartX, StartY, BoxWidth, BoxHeight As Integer
-
Dim GraphicxLoc, GraphicyLoc As Integer
-
Friend DrawingItems As Collection
-
-
Dim frmGrapher As Grapher
-
Dim GrapherTransparencyKey As Color
-
Dim DebugOutputComplete As Boolean = False
-
Public start As Integer
-
Private Declare Function GetScrollInfo Lib "user32" (ByVal hwnd As Long, ByVal n As Long, ByVal lpScrollInfo As SCROLLINFO) As Long
-
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
-
-
Const SIF_RANGE = &H1
-
Const SB_VERT = 1
-
-
Dim lHeight As Long, OnePixel As Long
-
Dim S As SCROLLINFO
-
Private Declare Auto Function SendScrollPosMessage _
-
Lib "user32.dll" Alias "SendMessage" ( _
-
ByVal hWnd As IntPtr, _
-
ByVal Msg As Integer, _
-
ByVal wParam As IntPtr, _
-
ByRef lParam As Point) As Integer
-
Private Const WM_USER = &H400
-
Private Const EM_GETSCROLLPOS = WM_USER + 221
-
Private Const EM_SETSCROLLPOS = WM_USER + 222
-
-
Private Structure POINTAPI
-
Public X As Integer
-
Public Y As Integer
-
End Structure
-
Private Structure SCROLLINFO
-
Public cbSize As Long
-
Public fMask As Long
-
Public nMin As Long
-
Public nMax As Long
-
Public nPage As Long
-
Public nPos As Long
-
Public nTrackPos As Long
-
End Structure
-
-
Private Declare Function GetCursorPos _
-
Lib "user32" (ByVal lpPoint As POINTAPI) As Integer
-
Private Declare Function GetDC _
-
Lib "user32" (ByVal hwnd As Integer) As Integer
-
Private Declare Function GetPixel _
-
Lib "gdi32" (ByVal hdc As Integer, _
-
ByVal X As Integer, ByVal Y As Integer) As Integer
-
Private Declare Function ReleaseDC _
-
Lib "user32" (ByVal hwnd As Integer, _
-
ByVal hdc As Integer) As Integer
-
-
Private lDesktopDC As Integer
-
-
Private Sub Timer1_Tick(ByVal sender As Object, _
-
ByVal e As System.EventArgs)
-
-
Dim tPt As Point, lRGB As Integer
-
tPt = MousePosition
-
lRGB = GetPixel(lDesktopDC, tPt.X, tPt.Y)
-
If lRGB <> -1 Then
-
Me.BackColor = ColorTranslator.FromWin32(lRGB)
-
End If
-
-
End Sub
'Code is in continuation (see next post)
- Private Sub frmPixelColor_Load(ByVal sender As Object, _
-
ByVal e As System.EventArgs) Handles MyBase.Load
-
'TransparentRichTextBox1.Parent = zRTB
-
AlphaRichTextBox.TransparentRichTextBox.Block = True
-
zRTB.SelectionHangingIndent = 1000
-
lDesktopDC = GetDC(0)
-
Dim i As Integer = zRTB.SelectionType
-
-
-
-
-
Dim word As New Word.Application
-
Dim doc As Word.Document
-
-
-
'filter which files to open
-
Me.OpenFileDialog1.Filter = "Word Docs (*.doc)|*.doc|All files|*.*"
-
' Dim result As DialogResult = OpenFileDialog1.ShowDialog(Me)
-
-
-
'If (result = Windows.Forms.DialogResult.OK) Then
-
-
-
-
' doc = word.Documents.Open(Me.OpenFileDialog1.FileName.ToString.Trim)
-
' 'doc.Words.Application.System.Parent = Me
-
-
' doc.UpdateStylesOnOpen = True
-
-
'End If
-
'Timer1.Interval = 100
-
'Timer1.Enabled = True
-
End Sub
-
-
Private Sub frmPixelColor_Closed(ByVal sender As Object, _
-
ByVal e As System.EventArgs) Handles MyBase.Closed
-
-
Call ReleaseDC(0, lDesktopDC)
-
End Sub
-
-
-
-
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
-
LinePen = New Pen(SolidBrush, 1)
-
-
MeGraphics = Me.zRTB.CreateGraphics
-
-
frmGrapher = New Grapher(Me)
-
-
End Sub
-
-
Private Sub DrawingPaletteButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DrawingPaletteButton.Click
-
Try
-
Me.zRTB.Cursor = Cursors.Cross
-
Me.zRTB.SelectionStart = 1
-
-
DrawingMode = True
-
Catch exc As Exception
-
End Try
-
End Sub
-
-
Private Sub OpenFileMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenFileMenuItem.Click
-
DrawingItems = New Collection
-
-
If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
-
zRTB.LoadFile(OpenFileDialog1.FileName)
-
End If
-
End Sub
-
-
Dim dummy As New RichTextBox
-
Private Sub MainTextRichTextbox_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles zRTB.MouseDown
-
DrawBoxX = e.X
-
DrawBoxY = e.Y
-
zRTB.SelectionStart = zRTB.GetCharIndexFromPosition(New Point(DrawBoxX, DrawBoxY))
-
'MainTextRichTextbox.SelectionHangingIndent = 1024
-
If DrawingMode Then
-
MouseDownDraw = True
-
start = zRTB.SelectionStart
-
End If
-
End Sub
-
-
Private Sub MainTextRichTextbox_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles zRTB.MouseMove
-
If Not MouseDownDraw Then
-
Exit Sub
-
End If
-
zRTB.SelectionLength = 0
-
-
-
If e.X > DrawBoxX Then
-
BoxWidth = e.X - DrawBoxX
-
StartX = DrawBoxX
-
Else
-
BoxWidth = DrawBoxX - e.X
-
StartX = e.X
-
End If
-
-
If e.Y > DrawBoxY Then
-
BoxHeight = e.Y - DrawBoxY
-
StartY = DrawBoxY
-
Else
-
BoxHeight = DrawBoxY - e.Y
-
StartY = e.Y
-
End If
-
zRTB.Refresh()
-
MeGraphics.DrawRectangle(LinePen, StartX, StartY, BoxWidth, BoxHeight)
-
zRTB.SelectionLength = 0
-
-
IsMultiselectOn = True
-
End Sub
-
Public Sub ClearScr()
-
zRTB.SelectAll()
-
zRTB.SelectionBackColor = Color.White
-
-
-
End Sub
-
Public Function GetLineLength(ByVal line As Integer) As Integer
-
Dim linesCount As Integer = zRTB.Lines.Length
-
If line <= linesCount Then
-
Return zRTB.Lines(line - 1).Length
-
End If
-
End Function
-
Dim IsMultiselectOn As Boolean
-
Private Sub MainTextRichTextbox_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles zRTB.MouseUp
-
-
DrawingMode = False
-
MouseDownDraw = False
-
-
-
-
-
-
-
-
-
If IsMultiselectOn Then
-
zRTB.SuspendLayout()
-
-
-
-
-
zRTB.SelectionStart = zRTB.GetCharIndexFromPosition(New Point(DrawBoxX, DrawBoxY))
-
Dim max As Integer = zRTB.GetCharIndexFromPosition(New Point(DrawBoxX + BoxWidth, DrawBoxY))
-
Dim FirstLine As Integer = zRTB.GetLineFromCharIndex(zRTB.GetCharIndexFromPosition(New Point(DrawBoxX + BoxWidth, DrawBoxY)))
-
zRTB.SelectionLength = max - zRTB.SelectionStart
-
Dim charwidth As Integer = max - zRTB.SelectionStart
-
Dim charindex As Integer = zRTB.SelectionStart - zRTB.GetFirstCharIndexFromLine(FirstLine)
-
Dim SelWidth As Integer = max - zRTB.SelectionStart
-
Dim backcolor As Color = zRTB.SelectionBackColor
-
Dim selectionclr As Color = zRTB.SelectionColor
-
-
zRTB.SelectionBackColor = Color.Blue
-
zRTB.SelectionColor = Color.White
-
Dim lines As Integer = zRTB.GetLineFromCharIndex(zRTB.GetCharIndexFromPosition(New Point(DrawBoxX, DrawBoxY + BoxHeight)))
-
If (lines - FirstLine > 0) Then
-
'more the one lines selected.
-
While (FirstLine < lines)
-
FirstLine += 1
-
Try
-
zRTB.SelectionStart = zRTB.GetFirstCharIndexFromLine(FirstLine) + charindex
-
-
If (zRTB.SelectedText.Contains(vbLf)) Then
-
zRTB.SelectionLength = (zRTB.SelectedText.IndexOf(vbCrLf) - zRTB.SelectionStart)
-
Else
-
zRTB.SelectionLength = charwidth
-
End If
-
-
Catch ex As Exception
-
Continue While
-
End Try
-
zRTB.SelectionBackColor = Color.Blue
-
zRTB.SelectionColor = Color.White
-
End While
-
End If
-
-
zRTB.SelectionLength = 0
-
zRTB.ResumeLayout()
-
-
-
zRTB.ResumeLayout()
-
IsMultiselectOn = False
-
End If
-
'draw area
-
-
-
End Sub
-
-
Private Sub FillRect()
-
Try
-
Dim height As Integer = 0
-
Dim width As Integer = 0
-
MeGraphics = zRTB.CreateGraphics
-
While (height <> BoxHeight)
-
While (width <> BoxWidth)
-
-
Dim lRGB As Integer = GetPixel(lDesktopDC, StartX, StartY)
-
Dim col As Color = ColorTranslator.FromWin32(lRGB)
-
If (col = Color.Black) Then
-
MeGraphics.DrawRectangle(Pens.White, StartX, StartY, StartX + 1, StartY + 1)
-
Else
-
MeGraphics.DrawLine(Pens.Yellow, StartX, StartY, StartX + 1, StartY + 1)
-
End If
-
StartY += 1
-
width += 1
-
-
End While
-
StartX += 1
-
height += 1
-
width = 0
-
End While
-
Call ReleaseDC(0, lDesktopDC)
-
-
Catch ex As Exception
-
-
End Try
-
End Sub
'Continue
- Private Sub DisplayMultiSelection()
-
Try
-
zRTB.SelectionStart = zRTB.GetCharIndexFromPosition(New Point(DrawBoxX, DrawBoxY))
-
Dim max As Integer = zRTB.GetCharIndexFromPosition(New Point(DrawBoxX + BoxWidth, DrawBoxY))
-
Dim FirstLine As Integer = zRTB.GetLineFromCharIndex(zRTB.GetCharIndexFromPosition(New Point(DrawBoxX + BoxWidth, DrawBoxY)))
-
zRTB.SelectionLength = max - zRTB.SelectionStart
-
Dim charwidth As Integer = max - zRTB.SelectionStart
-
Dim charindex As Integer = zRTB.SelectionStart - zRTB.GetFirstCharIndexFromLine(FirstLine)
-
-
-
Dim backcolor As Color = zRTB.SelectionBackColor
-
Dim selectionclr As Color = zRTB.SelectionColor
-
-
zRTB.SelectionBackColor = Color.Blue
-
zRTB.SelectionColor = Color.White
-
-
Dim lines As Integer = zRTB.GetLineFromCharIndex(zRTB.GetCharIndexFromPosition(New Point(DrawBoxX, DrawBoxY + BoxHeight)))
-
If (lines - FirstLine > 0) Then
-
'more the one lines selected.
-
While (FirstLine < lines)
-
FirstLine += 1
-
zRTB.SelectionStart = zRTB.GetFirstCharIndexFromLine(FirstLine) + charindex
-
zRTB.SelectionLength = charwidth
-
zRTB.SelectionBackColor = Color.Blue
-
zRTB.SelectionColor = Color.White
-
End While
-
End If
-
'MainTextRichTextbox.SelectionBackColor = backcolor
-
'MainTextRichTextbox.SelectionColor = selectionclr
-
Catch ex As Exception
-
-
End Try
-
End Sub
-
-
Private Sub MainTextRichTextbox_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles zRTB.SelectionChanged
-
If DrawingMode Then
-
Return
-
'zRTB.Select(0, 0)
-
'MainTextRichTextbox.SelectionLength = 0
-
End If
-
End Sub
-
-
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
-
PaintGraphics()
-
End Sub
-
-
Friend Sub PaintGraphics()
-
Dim ThisDrawItem As New Grapher.DrawingItem
-
Dim xLoc, yLoc As Integer
-
Dim xEndLoc, yEndLoc As Integer
-
-
zRTB.Refresh()
-
If Not IsNothing(DrawingItems) Then
-
-
For Each ThisDrawItem In DrawingItems
-
With ThisDrawItem
-
.PaletteX = .PaletteX
-
.PaletteY = .PaletteY
-
xLoc = .PaletteX + .StartPostion.X
-
-
xEndLoc = (.PaletteX) + .EndPostion.X
-
-
yLoc = .PaletteY + .StartPostion.Y + (YOffset - 50)
-
yEndLoc = .PaletteY + .EndPostion.Y + (YOffset - 50)
-
-
If Not DebugOutputComplete Then
-
DebugOutputComplete = True
-
End If
-
-
Select Case ThisDrawItem.DrawingMode
-
Case Grapher.DrawingModes.Rectangle
-
'MeGraphics.DrawRectangle(LinePen, xLoc, yLoc, .BoxSize.Width, .BoxSize.Height)
-
MeGraphics.DrawRectangle(LinePen, xLoc, yLoc, .BoxSize.Width, .BoxSize.Height)
-
Case Grapher.DrawingModes.Line
-
MeGraphics.DrawLine(LinePen, xLoc, yLoc, xEndLoc, yEndLoc)
-
Case Else
-
End Select
-
End With
-
Next
-
End If
-
-
'Test guidelines
-
If ShowGuidesMenuItem.Checked Then
-
MeGraphics.DrawLine(LinePen, 60, 0, 60, Me.Height)
-
MeGraphics.DrawLine(LinePen, 0, 60, Me.Width, 60)
-
End If
-
End Sub
-
-
Private Sub ShowGuidesMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShowGuidesMenuItem.Click
-
If ShowGuidesMenuItem.Checked Then
-
ShowGuidesMenuItem.Checked = False
-
Else
-
ShowGuidesMenuItem.Checked = True
-
End If
-
-
PaintGraphics()
-
End Sub
-
-
Private Sub CloseFileMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseFileMenuItem.Click
-
DrawingItems = New Collection
-
zRTB.ResetText()
-
End Sub
-
-
Private Sub MainTextRichTextbox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles zRTB.TextChanged
-
PaintGraphics()
-
End Sub
-
-
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize
-
If Not MeGraphics Is Nothing Then
-
MeGraphics.Dispose()
-
MeGraphics = Nothing
-
End If
-
MeGraphics = Me.zRTB.CreateGraphics
-
End Sub
-
-
Private Sub Form1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
-
-
End Sub
-
-
Private Sub TransparentRichTextBox1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
-
DrawBoxX = e.X
-
DrawBoxY = e.Y
-
zRTB.SelectionStart = zRTB.GetCharIndexFromPosition(New Point(DrawBoxX, DrawBoxY))
-
-
If DrawingMode Then
-
MouseDownDraw = True
-
End If
-
End Sub
-
-
Private Sub TransparentRichTextBox1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
-
-
If Not MouseDownDraw Then
-
Exit Sub
-
End If
-
-
If e.X > DrawBoxX Then
-
BoxWidth = e.X - DrawBoxX
-
StartX = DrawBoxX
-
Else
-
BoxWidth = DrawBoxX - e.X
-
StartX = e.X
-
End If
-
-
If e.Y > DrawBoxY Then
-
BoxHeight = e.Y - DrawBoxY
-
StartY = DrawBoxY
-
Else
-
BoxHeight = DrawBoxY - e.Y
-
StartY = e.Y
-
End If
-
-
' Me.Refresh()
-
-
' MeGraphics.DrawRectangle(LinePen, StartX, StartY, BoxWidth, BoxHeight)
-
End Sub
-
-
Private Sub TransparentRichTextBox1_Move(ByVal sender As System.Object, ByVal e As System.EventArgs)
-
-
End Sub
-
-
Private Sub TransparentRichTextBox1_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
-
DrawingMode = False
-
MouseDownDraw = False
-
End Sub
-
-
Private Sub MainTextRichTextbox_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles zRTB.KeyDown
-
Try
-
-
Catch ex As Exception
-
-
End Try
-
End Sub
-
Private Sub MainTextRichTextbox_VScroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles zRTB.VScroll
-
zRTB.Refresh()
-
End Sub
-
-
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
-
-
End Sub
-
-
Private Sub zRTB_MouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles zRTB.MouseHover
-
-
End Sub
-
End Class
copy and paste this code and press platter button and try to select area you will be able to select in block mode but its not perfect as avaiable with other editors
Boy that's alot of code to paste, I think that AricC meant only the code that you had tried to solve this requirement and was causing you problems...
Here is a blog that will get you started: XAML, WPF, .NET, Office 2007, Windows
For actual user selection behaviour you may need a custom control or dhtml behaviour. HTH.
CDave,
Did you get any solution for the "richtextbox" block selection.
Looking for the same, but no luck.
A RichTextBox doesn't select like that. You could make a custom control that inherits from RTB and handle the mousedown/mouseup events to create a custom control with the behavior you want.
You might also look around at the various .NET custom control making software companies for something already made that does what you want. Sometimes its cheaper to buy for $50 than your time for 10 hours to figure it out. Of course you don't learn by buying.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: deko |
last post by:
Problem: why doesn't this With block work? is it possible to have a For
Each loop within a With block?
With objWord
.Documents.Add Template:=strTemplate, NewTemplate:=False,
DocumentType:=0...
|
by: Sun Of Man |
last post by:
Is there anyway to set the BackColor of selected text in a RichTextBox? There's no problem doing it for the ForeColor.
Thanks in advance.
|
by: Leon Friesema |
last post by:
Hiyall!
I have a RichTextBox inside a UserControl which should be able to
indent a block off text (or UnIndent for that matter) like the
SourceEditor of VS2003 or WinWord does.
All controls on...
|
by: Nadeem |
last post by:
Hi,
I have a richtexbox and in that I am selecting some text in a button's click
event. This is working fine but the problem is if selection is consisted of
may pages it takes me to the end of...
|
by: Leon Friesema |
last post by:
Hi,
I'm working on a RichTextBox with some "in-program" style-features
(e.g. *no way* becomes bold : like MS Word does). Got everything
working fine, flickerfree and reasonable fast, but in...
|
by: =?Utf-8?B?Q29yZXlNY0s=?= |
last post by:
I'm working on a TextBox control (in C# using .NET 2.0) that allows fields
(like MS Office's mail merge feature). I want the editor to treat the field
as though it was a single character. The user...
|
by: jj |
last post by:
I'm going mad!
I'm exporting a query to excel, and afterwards calculating a field, and a
sum of all fields in Excel from a sub procedure in a Module in Access.
First I used
...
|
by: Whasigga |
last post by:
Hello
I am working on a project to export data from a query into an Excel file. I have a form with a button on it and the button when clicked runs a function that is supposed to run the query and...
|
by: kpr2009 |
last post by:
How to achieve block selection effect in winforms, Richtextbox.
Block selection:
1. Open a MS word document and type few lines.
2. Keep the cursor at middle of the first line
3. Press ALT + drag...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |