Click here to Skip to main content
15,891,607 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: connecting Access v. 95 DB over LAN vb6 win7 OS [RESOLVED] Pin
loid grey manuel30-Mar-11 20:20
loid grey manuel30-Mar-11 20:20 
Questionget Download Time of a File [Solved] Pin
εїзεїзεїз24-Mar-11 0:27
εїзεїзεїз24-Mar-11 0:27 
AnswerRe: get Download Time of a File Pin
Luc Pattyn24-Mar-11 1:48
sitebuilderLuc Pattyn24-Mar-11 1:48 
AnswerRe: get Download Time of a File Pin
Dave Kreskowiak24-Mar-11 2:00
mveDave Kreskowiak24-Mar-11 2:00 
AnswerRe: get Download Time of a File Pin
Dalek Dave24-Mar-11 4:08
professionalDalek Dave24-Mar-11 4:08 
AnswerRe: get Download Time of a File Pin
Аslam Iqbal24-Mar-11 12:10
professionalАslam Iqbal24-Mar-11 12:10 
AnswerRe: get Download Time of a File [Solved] Pin
εїзεїзεїз25-Mar-11 1:26
εїзεїзεїз25-Mar-11 1:26 
QuestionContextMenuStrip Pin
Dominick Marciano21-Mar-11 8:41
professionalDominick Marciano21-Mar-11 8:41 
I have several text boxes on my form each with the same right-click menu. Some of the items it has are cut, copy, paste, spell checking, and auto text entries. I have everything working except for the auto-text entries because I can not figure out how to get which text box the menu is attached to. The code I have right now (which is working) is when the menu is opened to determine which items should be enabled (for example if there is no text on the clipboard the paste menu item should be disabled):
Private Sub RightClickContextMenuStrip_Opened(ByVal sender As Object, ByVal e As System.EventArgs) Handles RightClickContextMenuStrip.Opened
    Dim cms As ContextMenuStrip
    Dim TempTextBox As TextBox

    cms = CType(sender, ContextMenuStrip)

    If TypeOf (cms.SourceControl) Is TextBox Then
        TempTextBox = CType(cms.SourceControl, TextBox)
        If Not String.IsNullOrEmpty(TempTextBox.SelectedText) AndAlso TempTextBox.ReadOnly = False Then
            mnuCut.Enabled = True
            mnuCopy.Enabled = True
        Else
            mnuCut.Enabled = False
            mnuCopy.Enabled = False
        End If

        If Clipboard.ContainsText Then
            mnuPaste.Enabled = True
        Else
            mnuPaste.Enabled = False
        End If

        If My.Settings.AutoText Is Nothing OrElse My.Settings.AutoText.Count < 1 Then
            mnuRightClickAutoText.Enabled = False
        Else
            mnuRightClickAutoText.DropDownItems.Clear()
            For Each item As String In My.Settings.AutoText
                Dim AutoTextItem As ToolStripItem
                AutoTextItem = mnuRightClickAutoText.DropDownItems.Add(item)
                AddHandler AutoTextItem.Click, AddressOf AutoText_Click
            Next
        End If
    End If
End Sub


Now I have a function that captures which auto text sub-menu item is clicked, but I can't figure out how to find out which text box the menu is attached to. Here is my code thus far:
Private Sub AutoText_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim cms As ContextMenuStrip
        Dim dpm As ToolStripDropDownMenu
        Dim Item As ToolStripItem
        Dim TempTextBox As TextBox
        Dim selectionIndex As Integer

        Item = CType(sender, ToolStripItem)
        cms = CType(Item.OwnerItem.Owner, ContextMenuStrip)

        If TypeOf (cms.SourceControl) Is TextBox Then
            TempTextBox = CType(cms.SourceControl, TextBox)
            selectionIndex = TempTextBox.SelectionStart
            TempTextBox.Text = TempTextBox.Text.Insert(selectionIndex, Item.Text)
            TempTextBox.SelectionStart = selectionIndex + Item.Text.Length
        End If

    End Sub


However with this code the cms.SourceControl is nothing. The menu is set up like this

Cut
Copy
Paste
------
AutoText -> Item1, Item2, Item3
------
Basic Filter
Advanced Filter

I'm capturing the click events on Item1, Item2, etc. but can't figure out what text box they go to. How do I get the source control in this circumstance. Thanks in advanced for any help.
AnswerRe: ContextMenuStrip Pin
Luc Pattyn21-Mar-11 9:01
sitebuilderLuc Pattyn21-Mar-11 9:01 
GeneralRe: ContextMenuStrip Pin
Dominick Marciano21-Mar-11 13:44
professionalDominick Marciano21-Mar-11 13:44 
QuestionCryptCreateHash returns zero, invalid parameter Pin
garfield18521-Mar-11 5:26
garfield18521-Mar-11 5:26 
AnswerRe: CryptCreateHash returns zero, invalid parameter Pin
Luc Pattyn21-Mar-11 5:39
sitebuilderLuc Pattyn21-Mar-11 5:39 
GeneralRe: CryptCreateHash returns zero, invalid parameter Pin
garfield18521-Mar-11 5:48
garfield18521-Mar-11 5:48 
GeneralRe: CryptCreateHash returns zero, invalid parameter Pin
Dave Kreskowiak21-Mar-11 6:25
mveDave Kreskowiak21-Mar-11 6:25 
AnswerRe: CryptCreateHash returns zero, invalid parameter Pin
Luc Pattyn21-Mar-11 7:02
sitebuilderLuc Pattyn21-Mar-11 7:02 
Question[SOLVED] How to Insert / update value in Microsoft Access Database via UDP? [modified] Pin
Yance Lawang21-Mar-11 2:58
Yance Lawang21-Mar-11 2:58 
AnswerRe: How to Insert / update value in Microsoft Access Database via UDP? Pin
Dave Kreskowiak21-Mar-11 4:08
mveDave Kreskowiak21-Mar-11 4:08 
GeneralRe: How to Insert / update value in Microsoft Access Database via UDP? [modified] Pin
Yance Lawang21-Mar-11 13:45
Yance Lawang21-Mar-11 13:45 
GeneralRe: How to Insert / update value in Microsoft Access Database via UDP? Pin
Dave Kreskowiak21-Mar-11 14:48
mveDave Kreskowiak21-Mar-11 14:48 
GeneralRe: How to Insert / update value in Microsoft Access Database via UDP? Pin
Yance Lawang21-Mar-11 17:03
Yance Lawang21-Mar-11 17:03 
GeneralRe: How to Insert / update value in Microsoft Access Database via UDP? Pin
Dave Kreskowiak21-Mar-11 18:06
mveDave Kreskowiak21-Mar-11 18:06 
GeneralRe: How to Insert / update value in Microsoft Access Database via UDP? Pin
Yance Lawang21-Mar-11 20:10
Yance Lawang21-Mar-11 20:10 
GeneralRe: How to Insert / update value in Microsoft Access Database via UDP? [modified] Pin
Yance Lawang23-Mar-11 16:21
Yance Lawang23-Mar-11 16:21 
GeneralRe: How to Insert / update value in Microsoft Access Database via UDP? Pin
Dave Kreskowiak23-Mar-11 17:55
mveDave Kreskowiak23-Mar-11 17:55 
GeneralRe: How to Insert / update value in Microsoft Access Database via UDP? Pin
Yance Lawang23-Mar-11 20:06
Yance Lawang23-Mar-11 20:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.