Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    Regular Coder
    Join Date
    Jul 2007
    Location
    Velsen Noord, Netherlands
    Posts
    206
    Thanks
    6
    Thanked 0 Times in 0 Posts

    [VB2010] Email addresses from datagridview to textbox

    I want to know how I can select multiple emailaddresses (rows) in a datagridview and enter them separated by a semicolon in a textbox or select select a single row press the add button to add the emailaddress to the textbox, then select another row and after pressing the add button again that emailaddress is entered into the textbox, behind the first add emailaddress separated by a semicolon.

    Just like with outlook.

    Can anyone help me with this?

  • #2
    Regular Coder
    Join Date
    Jul 2007
    Location
    Velsen Noord, Netherlands
    Posts
    206
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Doesn't anyone has an answer for the problem?

  • #3
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    You should probably mention the language you would like help in.

  • #4
    Regular Coder
    Join Date
    Jul 2007
    Location
    Velsen Noord, Netherlands
    Posts
    206
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Inigoesdr View Post
    You should probably mention the language you would like help in.
    My bad, I use VB2010

  • #5
    Regular Coder
    Join Date
    Jul 2007
    Location
    Velsen Noord, Netherlands
    Posts
    206
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Is there no one who can help me with this?

    There must be someone?

  • #6
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,711
    Thanks
    41
    Thanked 191 Times in 190 Posts
    .net mail to

    then somewhere before this line
    Code:
    Dim [to] As New MailAddress("ben@contoso.com")
    populate a string array with emails and then do
    Code:
    ......MailAddress(strEmails[0] + ";" + strEmails[1]..... and so on (side note... i think VB uses & instead of +)
    then you could similarly populate the textbox with it or am i missing something (*hope this answers Q)
    textbox1.Text= "whatever you want"

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE

  • #7
    Regular Coder
    Join Date
    Jul 2007
    Location
    Velsen Noord, Netherlands
    Posts
    206
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Thanks for your reply.

    What I try is something similar to the microsoft office outlook 2007, when creating a new email, and then To.. to select the addresses. This is the part I'm looking for (see attachment), when selecting an address in the list and press the TO..., CC.. or BCC button to add the email address to the textbox.

    How to do that?
    Attached Thumbnails Attached Thumbnails [VB2010] Email addresses from datagridview to textbox-office-outlook.jpg  
    Last edited by UD2006; 10-15-2011 at 01:19 PM. Reason: forgot to add the image as attachment

  • #8
    New Coder
    Join Date
    Sep 2011
    Posts
    45
    Thanks
    1
    Thanked 6 Times in 6 Posts
    cycle through the data to get the selected fields, something like this:

    Code:
            For i = 0 To DataGridView1.Rows.Count - 1
                If DataGridView1.Rows(i).Cells("EMail").Selected Then
                    'do stuff to  DataGridView1.Rows(i).
                End If
            Next

  • #9
    Regular Coder
    Join Date
    Jul 2007
    Location
    Velsen Noord, Netherlands
    Posts
    206
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Sorry for replying after a long period.

    I've been trying get it working and came up with the following code:
    Code:
    Private Sub ToButton_Click(sender As System.Object, e As System.EventArgs) Handles ToButton.Click
            Dim tmpstr As String = ""
            Dim cnt As Integer = 0
            Dim virgin As Boolean = True
            For cnt = 0 To (DataGridViewX1.Rows.Count - 1)
                If Not DataGridViewX1.Rows(cnt).Cells(3).Value.ToString() Is Nothing Then
                    If Not DataGridViewX1.Rows(cnt).Cells(3).Value.ToString().Length = 0 Then
                        If Not virgin Then
                            tmpstr += "; "
                        End If
                        tmpstr += DataGridViewX1.Rows(cnt).Cells(3).Value.ToString()
                        virgin = False
                        'MsgBox(tmpstr)
                    End If
                End If
            Next
            ToTextBox.Text = tmpstr
        End Sub
    The problem with this code is that it even if I only select one row, it enters all the rows (email addresses, separated by semicolon) into the textbox.

    What I want is to be able to select a single row and add that email address to the textbox, and when I select another row I want to add that email address to the textbox, behind the first entered email address (just as outlook).

    Thanks


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •