Private Sub lbAll_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lbAll.MouseDown
'If lbAll.Items.Count = 0 Then
' Return
'End If
'Dim s As String = lbAll.Items(lbAll.IndexFromPoint(e.X, e.Y)).ToString()
'Dim dde1 As DragDropEffects = DoDragDrop(s, DragDropEffects.All)
'If dde1 = DragDropEffects.All Then
' 'lbAll.Items.RemoveAt(lbAll.IndexFromPoint(e.X, e.Y))
'End If
lbAll.DoDragDrop(lbAll.SelectedItems, DragDropEffects.Move)
End Sub
Private Sub lbSelected_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles lbSelected.DragDrop
'If e.Data.GetDataPresent(DataFormats.StringFormat) Then
' Dim str As String = DirectCast(e.Data.GetData(DataFormats.StringFormat), String)
' lbSelected.Items.Add(str)
'End If
For Each item As Object In (e.Data.GetData(GetType(ListBox.SelectedObjectCollection)))
lbSelected.Items.Add(item)
Next
End Sub
Private Sub lbSelected_DragOver(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles lbSelected.DragOver
' e.Effect = DragDropEffects.All
If (e.Data.GetDataPresent(GetType(ListBox.SelectedObjectCollection))) Then
e.Effect = DragDropEffects.Move
Else
e.Effect = DragDropEffects.None
End If
End Sub
Thursday, September 8, 2011
Monday, September 5, 2011
Connection String for .xls and .xlsx
MyConnection = New System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; Data Source='" & G_FilePath & "'; Extended Properties=Excel 8.0;")
Else
MyConnection = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" & G_FilePath & "';Extended Properties=""Excel 12.0;HDR=Yes;IMEX=2""")
End If
Else
MyConnection = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" & G_FilePath & "';Extended Properties=""Excel 12.0;HDR=Yes;IMEX=2""")
End If
Tuesday, August 30, 2011
Tuesday, August 23, 2011
Send mail in vb.net ,desktop applicaton
Dim Mail As New MailMessage()
Mail.To.Add(New MailAddress("tomail@gmail.com"))
Mail.From = (New MailAddress("frommail@gmail.com"))
Mail.Subject = "Mail subject"
Mail.Body = "Mail body"
Mail.IsBodyHtml = True
Dim smtpClient As New SmtpClient("smtp.gmail.com")
smtpClient.Host = "smtp.gmail.com"
smtpClient.Port = 587
smtpClient.EnableSsl = True
Dim userpass As New Net.NetworkCredential("frommail@gmail.com", "frommail_password")
smtpClient.Credentials = userpass
smtpClient.Send(Mail)
MessageBox.Show("Mail Send")
Mail.To.Add(New MailAddress("tomail@gmail.com"))
Mail.From = (New MailAddress("frommail@gmail.com"))
Mail.Subject = "Mail subject"
Mail.Body = "Mail body"
Mail.IsBodyHtml = True
Dim smtpClient As New SmtpClient("smtp.gmail.com")
smtpClient.Host = "smtp.gmail.com"
smtpClient.Port = 587
smtpClient.EnableSsl = True
Dim userpass As New Net.NetworkCredential("frommail@gmail.com", "frommail_password")
smtpClient.Credentials = userpass
smtpClient.Send(Mail)
MessageBox.Show("Mail Send")
Friday, August 19, 2011
Thursday, August 18, 2011
get gridview rowindex commandargument
delete a perticular row by rowindex
protected void grdRoomNumber_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Delete")
{
grdRoomNumber.DeleteRow(Convert.ToInt32(e.CommandArgument));
}
}
Sunday, August 7, 2011
RANDOM DATATABLE ROW
static Random _rand = new Random();
public DataView RandomizeDataTable(DataTable dt)
{
// Create array of indices and populate with ordinal values
int[] indices = new int[dt.Rows.Count];
for (int i = 0; i < indices.Length; i++)
indices[i] = i;
// Knuth-Fisher-Yates shuffle indices randomly
for (int i = indices.Length - 1; i > 0; i--)
{
int n = _rand.Next(i + 1);
int tmp = indices[i];
indices[i] = indices[n];
indices[n] = tmp;
}
// Add new column to data table (if it's not there already)
// to store shuffle index
if (dt.Columns["rndSortId"] == null)
dt.Columns.Add(new DataColumn("rndSortId", typeof(int)));
int rndSortColIdx = dt.Columns["rndSortId"].Ordinal;
for (int i = 0; i < dt.Rows.Count; i++)
dt.Rows[i][rndSortColIdx] = indices[i];
DataView dv = new DataView(dt);
dv.Sort = "rndSortId";
return dv;
}
public DataView RandomizeDataTable(DataTable dt)
{
// Create array of indices and populate with ordinal values
int[] indices = new int[dt.Rows.Count];
for (int i = 0; i < indices.Length; i++)
indices[i] = i;
// Knuth-Fisher-Yates shuffle indices randomly
for (int i = indices.Length - 1; i > 0; i--)
{
int n = _rand.Next(i + 1);
int tmp = indices[i];
indices[i] = indices[n];
indices[n] = tmp;
}
// Add new column to data table (if it's not there already)
// to store shuffle index
if (dt.Columns["rndSortId"] == null)
dt.Columns.Add(new DataColumn("rndSortId", typeof(int)));
int rndSortColIdx = dt.Columns["rndSortId"].Ordinal;
for (int i = 0; i < dt.Rows.Count; i++)
dt.Rows[i][rndSortColIdx] = indices[i];
DataView dv = new DataView(dt);
dv.Sort = "rndSortId";
return dv;
}
Subscribe to:
Posts (Atom)
