Web Analytics Made Easy -
StatCounter [VB2010] Email addresses from datagridview to textbox - CodingForum

Announcement

Collapse
No announcement yet.

[VB2010] Email addresses from datagridview to textbox

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new 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
    Doesn't anyone has an answer for the problem?

    Comment


    • #3
      You should probably mention the language you would like help in.

      Comment


      • #4
        Originally posted by Inigoesdr View Post
        You should probably mention the language you would like help in.
        My bad, I use VB2010

        Comment


        • #5
          Is there no one who can help me with this?

          There must be someone?

          Comment


          • #6
            .net mail to

            then somewhere before this line
            Code:
            Dim [to] As New MailAddress("[email protected]")
            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

            Comment


            • #7
              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 Files
              Last edited by UD2006; Oct 15, 2011, 08:19 AM. Reason: forgot to add the image as attachment

              Comment


              • #8
                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

                Comment


                • #9
                  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

                  Comment

                  Working...
                  X
                  😀
                  🥰
                  🤢
                  😎
                  😡
                  👍
                  👎