ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Send SMS to Checked (Selected) Rows of DataGridView in Windows Application using C# and VB.Net<p>Hey <a class="username" rel="satabeach">satabeach</a>,</p> <p>Please refer below sample.</p> <p><span style="text-decoration: underline;"><strong>Namespaces</strong></span></p> <pre class="brush: csharp">using System.Data; </pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Imports System.Data</pre> <p><span style="text-decoration: underline;"><strong>Code</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">private void Form1_Load(object sender, EventArgs e) { this.BindDataGridView(); } private void BindDataGridView() { DataTable dt = new DataTable(); dt.Columns.AddRange(new DataColumn[3] { new DataColumn(&#34;ContactNumber&#34;, typeof(int)), new DataColumn(&#34;Name&#34;, typeof(string)), new DataColumn(&#34;Messaage&#34;,typeof(string)) }); dt.Rows.Add(123456, &#34;John Hammond&#34;, &#34;Hey&#34;); dt.Rows.Add(235489, &#34;Mudassar Khan&#34;, &#34;Hello&#34;); dt.Rows.Add(345556, &#34;Suzanne Mathews&#34;, &#34;Hmmmm&#34;); dt.Rows.Add(466677, &#34;Robert Schidner&#34;, &#34;Whats&#39;up&#34;); this.dataGridView1.DataSource = dt; DataGridViewCheckBoxColumn checkBoxColumn = new DataGridViewCheckBoxColumn(); checkBoxColumn.HeaderText = &#34;&#34;; checkBoxColumn.Width = 30; checkBoxColumn.Name = &#34;checkBoxColumn&#34;; dataGridView1.Columns.Insert(0, checkBoxColumn); } private void Send(object sender, EventArgs e) { foreach (DataGridViewRow row in dataGridView1.Rows) { bool isSelected = Convert.ToBoolean(row.Cells[&#34;checkBoxColumn&#34;].Value); if (isSelected) { string contactNumber = row.Cells[1].Value.ToString(); string message = row.Cells[3].Value.ToString(); if (!SendSMS(message, contactNumber)) { MessageBox.Show(&#34;Problem occured while sending SMS&#34;, &#34;Erro&#34;, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } } private bool SendSMS(string message, string number) { //Send SMS Code that return the status. bool status = false; return status; }</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load Me.BindDataGridView() End Sub Private Sub BindDataGridView() Dim dt As DataTable = New DataTable() dt.Columns.AddRange(New DataColumn(2) {New DataColumn(&#34;ContactNumber&#34;, GetType(Integer)), New DataColumn(&#34;Name&#34;, GetType(String)), New DataColumn(&#34;Messaage&#34;, GetType(String))}) dt.Rows.Add(123456, &#34;John Hammond&#34;, &#34;Hey&#34;) dt.Rows.Add(235489, &#34;Mudassar Khan&#34;, &#34;Hello&#34;) dt.Rows.Add(345556, &#34;Suzanne Mathews&#34;, &#34;Hmmmm&#34;) dt.Rows.Add(466677, &#34;Robert Schidner&#34;, &#34;Whats&#39;up&#34;) Me.dataGridView1.DataSource = dt Dim checkBoxColumn As DataGridViewCheckBoxColumn = New DataGridViewCheckBoxColumn() checkBoxColumn.HeaderText = &#34;&#34; checkBoxColumn.Width = 30 checkBoxColumn.Name = &#34;checkBoxColumn&#34; dataGridView1.Columns.Insert(0, checkBoxColumn) End Sub Private Sub Send(ByVal sender As Object, ByVal e As EventArgs) Handles btnTransfer.Click For Each row As DataGridViewRow In dataGridView1.Rows Dim isSelected As Boolean = Convert.ToBoolean(row.Cells(&#34;checkBoxColumn&#34;).Value) If isSelected Then Dim contactNumber As String = row.Cells(1).Value.ToString() Dim message As String = row.Cells(3).Value.ToString() If Not SendSMS(message, contactNumber) Then MessageBox.Show(&#34;Problem occured while sending SMS&#34;, &#34;Erro&#34;, MessageBoxButtons.OK, MessageBoxIcon.Exclamation) End If End If Next End Sub Private Function SendSMS(ByVal message As String, ByVal number As String) As Boolean &#39;Send SMS Code that return the status. Dim status As Boolean = False Return status End Function</pre>https://www.aspforums.net:443/Threads/189829/Send-SMS-to-Checked-Selected-Rows-of-DataGridView-in-Windows-Application-using-C-and-VBNet/https://www.aspforums.net:443/Threads/189829/Send-SMS-to-Checked-Selected-Rows-of-DataGridView-in-Windows-Application-using-C-and-VBNet/Fri, 23 Nov 2018 00:31:24 GMT