Luc001 77 Posting Whiz

Hi,

To export a Crystal Report to PDF.
You can find some information, here.

To send an Email, try this:

Dim mail As New MailMessage()
mail.To = "me@mycompany.com"
mail.From = "you@yourcompany.com"
mail.Subject = "this is a test email."
mail.Body = "this is my test email body."
Dim attachment As New MailAttachment(Server.MapPath("test.pdf")) 'create the attachment
mail.Attachments.Add(attachment) 'add the attachment
SmtpMail.SmtpServer = "localhost" 'your real server goes here
SmtpMail.Send(mail)
Luc001 77 Posting Whiz

Hi,

You can find an example, here.

Luc001 77 Posting Whiz

Hi,

You can find some information about how to add an Image/Loge into a Crystal Report, here.

Luc001 77 Posting Whiz

Hi,

You need to iterate through the DataGridView rows and for each row, cast the cell in the column of interest to DataGridViewCheckBoxCell and cast the Value to a bool.

Luc001 77 Posting Whiz

Hi,

You can import:

Imports System.Data
Imports System.Data.SqlClient

I hope it helps.

Luc001 77 Posting Whiz

Hi,

You can try something like this:

Private Sub button1_Click(sender As Object, e As EventArgs)
	Dim strExport As String = ""
	'Loop through all the columns in DataGridView to Set the 
	'Column Heading
	For Each dc As DataGridViewColumn In dataGridView1.Columns
		strExport += dc.Name + "   "
	Next
	strExport = strExport.Substring(0, strExport.Length - 3) & Environment.NewLine.ToString()
	'Loop through all the row and append the value with 3 spaces
	For Each dr As DataGridViewRow In dataGridView1.Rows
		For Each dc As DataGridViewCell In dr.Cells
			If dc.Value IsNot Nothing Then
				strExport += dc.Value.ToString() & "   "
			End If
		Next
		strExport += Environment.NewLine.ToString()
	Next
	strExport = strExport.Substring(0, strExport.Length - 3) & Environment.NewLine.ToString()
	'Create a TextWrite object to write to file, select a file name with .csv extention
	Dim tw As System.IO.TextWriter = New System.IO.StreamWriter("data.csv")
	'Write the Text to file
	tw.Write(strExport)
	'Close the Textwrite
	tw.Close()
End Sub

I haven't tested it.

Luc001 77 Posting Whiz

Hi,

I should use a Class for this so that you can call it instead of writing the whole code over again.

Luc001 77 Posting Whiz

Hi,

What I meant with " myColumn" is the name of the column you want to be added into the autocomplete textbox.

Luc001 77 Posting Whiz

Hi,

This:

Else FutureJob = future

Should be:

Else 
FutureJob = future
Luc001 77 Posting Whiz

Hi,

I've one more question:
What will you do if the number doesn't match in listbox2?

Luc001 77 Posting Whiz

Hi,

The error message you've got is for wich line?

Luc001 77 Posting Whiz

Hi,

You can try this:

For Each dr As DataRow In myDataSet.myTable.Rows
	Me.toolStripTextBox1.AutoCompleteCustomSource.Add(dr("myColumn").ToString())
Next

Make sure you have your AutoCompleteSource set to CustomSource.

bLuEmEzzy commented: Thank u :) +3
Luc001 77 Posting Whiz

Hi,

To delete the last typed char you need this:

Private Sub btnBackSpace_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBackSpace.Click

        If (lblDisplay.Text.Length > 0) Then
            d = lblDisplay.Text.Length
            lblDisplay.Text = lblDisplay.Text.Remove(d - 1, 1)

        End If

    End Sub

To change the value signal, you need this:

Private Sub bttnNegate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttnNegate.Click
        lblDisplay.Text = -CSng(lblDisplay.Text)
        ClearDisplay = True
    End Sub
Luc001 77 Posting Whiz

Hi,

Here's an example how to save the listboxitems to a textfile:

Private Shared Sub WriteToFile()
	Dim SW As StreamWriter
	SW = File.Create("c:\MyTextFile.txt")
	For Each item As ListItem In ListBox.items
	SW.WriteLine(item.text)
	Next
	SW.Close()
End Sub
Luc001 77 Posting Whiz

Hi,

You should do something like this:

Private treeViewWithToolTips As TreeView

Private Sub InitializeTreeViewWithToolTips() 
    treeViewWithToolTips = New TreeView()
    Dim node1 As New TreeNode("Node1")
    node1.ToolTipText = "Help for Node1"
    Dim node2 As New TreeNode("Node2")
    node2.ToolTipText = "A Tip for Node2"
    treeViewWithToolTips.Nodes.AddRange(New TreeNode() {node1, node2})
    treeViewWithToolTips.ShowNodeToolTips = True
    Me.Controls.Add(treeViewWithToolTips)

End Sub
Luc001 77 Posting Whiz

Hi,

Here's an example:

Dim associatedChar As Char
' Returns "A".
associatedChar = Chr(65)
' Returns "a".
associatedChar = Chr(97)
' Returns ">".
associatedChar = Chr(62)
' Returns "%".
associatedChar = Chr(37)
Luc001 77 Posting Whiz

Hi,

You can find a Tic Tac Toe tutorial, here.

This one is the easyest one, just googled ;)

Luc001 77 Posting Whiz

Hi msqueen082,

It was no problem to help you with the other part of your code.

To avoid that other members will help you with your other problem: Julian dates.
You should first solved this thread and open another one with your Julian's dates problem.

Thanks in advance.

Luc001 77 Posting Whiz

I have to use dates in calculation ... like a client types a appointment datat in textbox and in another textbox it shows that the date has to be between two days.
(appointment written in text box has to be 90 days after today but less than 100 days and also appointment cannot be not less than 80 of today)

Hi,

I'm not that sure what you want about 100 days and 80 days, but here's a way how to do it with 90 days.

Dim ts As TimeSpan
                ts = aptDate.Subtract(dteToday)
            
                TextBox1.Text = "Confirmed:" & "  " & dteToday.AddDays(90) & " " & (", " & ts.Days & " " & "days until appointment")
Luc001 77 Posting Whiz

Hi,

Did you added that desktop icon again to the newer version setup of your application.
If not I think you should try that.

Luc001 77 Posting Whiz

Hi,

In the properties of the textboxes you doesn't want the focus set Tabstop = False
For the textbox set Tabindex = 0

hercx commented: thanks +2
Luc001 77 Posting Whiz

Hi,

You can find an example, here.

Luc001 77 Posting Whiz

Hi,

Did you had some errors?
How did you used that part of code?
...

Luc001 77 Posting Whiz

Hi,

You can try something like this:

Me.DataGridView1.Rows.Insert(0, value1, value2) ' values you entered

Didn't tested it

Luc001 77 Posting Whiz

Hi,

You should try something like this:

Dim item As ListItem
	For Each item In ListView1.ListItems
		If item.Selected = False Then
			'do your stuff here
		End If
	Next
Luc001 77 Posting Whiz

Dear Sir/Madam,

I have two form in my application form1 and form2. Here, i want to show the form2 from form1 by using a button. And i want to reverse back to my form1 from form2 using same technique. But i want to close form1 (Not visible=false or hide) after loading form2 and same thing in reverse back also.

I have tried like this....

'for from1
form2.show()
'form1.close ' not accepted
me.close

In my above code whole application is closing.

'for form2
form1.show()
me.close()

Here it is working in form2

I want to know that can we close our current form after showing another form? Please guide me.

Hi,

You just need to go to the properties of your application and set:

Shutdownmode = When last form closes

Your application will only close when last form closes.

Luc001 77 Posting Whiz

Guys how do I save settings of a form like its background color, fonstyle, sontsize etc. I cannot save them as string or text into my access database.

Hi Mark,

You can also try to do this with the My.Settings object.
You can find some information,here.

Luc001 77 Posting Whiz

thanks animal mother. it paints tabpage header. but it doesnt paint remaining part of the tab control... is ther any solution to this..

Hi Ashu26,

You can do it like this;

Private Sub TabControl1_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles TabControl1.DrawItem
        'Firstly we'll define some parameters.
        Dim CurrentTab As TabPage = TabControl1.TabPages(e.Index)
        Dim ItemRect As Rectangle = TabControl1.GetTabRect(e.Index)
        Dim FillBrush As New SolidBrush(Color.RoyalBlue)
        Dim TextBrush As New SolidBrush(Color.White)
        Dim sf As New StringFormat
        sf.Alignment = StringAlignment.Center
        sf.LineAlignment = StringAlignment.Center

        'If we are currently painting the Selected TabItem we'll 
        'change the brush colors and inflate the rectangle.
        If CBool(e.State And DrawItemState.Selected) Then
            FillBrush.Color = Color.White
            TextBrush.Color = Color.RoyalBlue
            TabPage1.BackColor = Color.LightBlue  ' change the backcloor of your tabpage1
            TabPage2.BackColor = Color.LightGreen ' Change backcolor of tabpage2
            ItemRect.Inflate(2, 2)
        End If

        'Set up rotation for left and right aligned tabs
        If TabControl1.Alignment = TabAlignment.Left Or TabControl1.Alignment = TabAlignment.Right Then
            Dim RotateAngle As Single = 90
            If TabControl1.Alignment = TabAlignment.Left Then RotateAngle = 270
            Dim cp As New PointF(ItemRect.Left + (ItemRect.Width \ 2), ItemRect.Top + (ItemRect.Height \ 2))
            e.Graphics.TranslateTransform(cp.X, cp.Y)
            e.Graphics.RotateTransform(RotateAngle)
            ItemRect = New Rectangle(-(ItemRect.Height \ 2), -(ItemRect.Width \ 2), ItemRect.Height, ItemRect.Width)
        End If

        'Next we'll paint the TabItem with our Fill Brush
        e.Graphics.FillRectangle(FillBrush, ItemRect)

        'Now draw the text.
        e.Graphics.DrawString(CurrentTab.Text, e.Font, TextBrush, RectangleF.op_Implicit(ItemRect), sf)

        'Reset any Graphics rotation
        e.Graphics.ResetTransform()

        'Finally, we should Dispose of our brushes.
        FillBrush.Dispose()
        TextBrush.Dispose()

    End Sub
Luc001 77 Posting Whiz

Hi,

To let the code that Animal Mother provided work.
You need to change in the properties of that Tabcontrol the Drawmode = OwnerDrawFixed

Luc001 77 Posting Whiz

Hi,

You could find some info, here.

Luc001 77 Posting Whiz

Hi chibex64,

Your code only shows a randomvalue and not the datetime.minute or datetime.year.
You should do it like this:

'declare variables
        Dim randomvalue As New Random   'create random object
        Dim randomhold As Integer

        'generate random number
        For i As Integer = 0 To 9999
            randomhold = randomvalue.Next(1, 9999)
            txtUserId.Text = randomhold & " " & DateTime.Now.Minute & "  " & DateTime.Now.Year
        Next
Luc001 77 Posting Whiz

Hi,

When you first open up a project written in VS 2008 inside VS 2010 it will normaly prompt you to upgrade the project. What this actually does is update the project (.vbproj) and solution .(sln) files to be compatible with VS 2010.

Did you tryed that?

Luc001 77 Posting Whiz

Guys, is there a way to programatically and more efficiently sort records displayed in a datagridview control? If so, how?

Hi,

You should use the Datagridview.Sort method.
You can make your sorting in a ascending or decending direction.

You can find an example, here.

Luc001 77 Posting Whiz

Hi,

You could mark this thread as solved.

Luc001 77 Posting Whiz

Hi,

You can try something like this:

Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged, _
    RadioButton2.CheckedChanged
        If RadioButton1.Checked Then
            MsgBox("You clicked Radiobutton1")
        End If
        If RadioButton2.Checked Then
            MsgBox("You clicked Radiobutton2")
        End If
    End Sub
Luc001 77 Posting Whiz

Hi,

If that solved your problem, mark this thread as solved.

Luc001 77 Posting Whiz

Hi,

You can try something like this:

EmailTextBox.Text = EmailGridView.Item(1, DataGridView1.SelectedRows(0).Index).Value
Luc001 77 Posting Whiz

Hi,

You can give the checkboxtext the same text as the listviewheader.

What you can do is the use a Datagridview instead and there you can add checkboxes.

Luc001 77 Posting Whiz

Hi,

You can't add a Checkbox into the listview header, but you can add a checkbox into the listview header and use this ccde to use it.

Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged

  For Each lvitem As ListViewItem In Me.ListView1.Items
   If lvitem.Checked = False Then
      lvitem.Checked = True
   Else
      lvitem.Checked = False
   End If
  Next

End Sub
Luc001 77 Posting Whiz

Hi,

Here's an example how to do it:

Private Sub PrintDocument1_BeginPrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles PrintDocument1.BeginPrint 
    '--- Start printing at the start of the string 
    mStringPos = 0 
  End Sub 

  Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage 
    '--- Setup graphics context 
    Dim fnt As New Font("Arial", 10) 
    e.Graphics.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias 
    '--- Calculate the number of characters that fit inside the margins 
    Dim area As SizeF = New SizeF(e.MarginBounds.Width, e.MarginBounds.Height) 
    Dim lines, chars As Integer 
    e.Graphics.MeasureString(PrintText.Substring(mStringPos), fnt, area, _ 
      StringFormat.GenericTypographic, chars, lines) 
    '--- Print the amount of text that fits inside the margins 
    Dim rc As New RectangleF(e.MarginBounds.Left, e.MarginBounds.Top, e.MarginBounds.Width, e.MarginBounds.Height) 
    e.Graphics.DrawString(PrintText.Substring(mStringPos, chars), fnt, _ 
      Brushes.Black, rc, StringFormat.GenericTypographic) 
    '--- Advance print position by <chars> 
    mStringPos += chars 
    '--- We'll need another page if not all characters got printed 
    e.HasMorePages = mStringPos < PrintText.Length 
    '--- Cleanup 
    fnt.Dispose() 
  End Sub
Luc001 77 Posting Whiz

Hi,

You can delete rows by first selecting the rows and then pressing the Delete key. If you may want to confirm the deletion with the user before deleting them. You can do this with the UserDeletingRow event:

Private Sub DataGridView1_UserDeletingRow( _
       ByVal sender As Object, _
       ByVal e As System.Windows.Forms. _
       DataGridViewRowCancelEventArgs) _
       Handles DataGridView1.UserDeletingRow
        If (Not e.Row.IsNewRow) Then
            Dim response As DialogResult = _
            MessageBox.Show( _
            "Are you sure you want to delete this row?", _
            "Delete row?", _
            MessageBoxButtons.YesNo, _
            MessageBoxIcon.Question, _
            MessageBoxDefaultButton.Button2)
            If (response = DialogResult.No) Then
                e.Cancel = True
            End If
        End If
    End Sub
Luc001 77 Posting Whiz

Hi y2kshane,

Thanks for the reputation points.
If that solved your problem mark it as solved.

Luc001 77 Posting Whiz

Hi,

You can try this:

'following code resizes picture to fit

        Dim bm As New Bitmap(PictureBox1.Image)
        Dim x As Int32 'variable for new width size
        Dim y As Int32 'variable for new height size

        Dim width As Integer = Val(x) 'image width. 

        Dim height As Integer = Val(y) 'image height

        Dim thumb As New Bitmap(width, height)

        Dim g As Graphics = Graphics.FromImage(thumb)

        g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic

        g.DrawImage(bm, New Rectangle(0, 0, width, height), New Rectangle(0, 0, bm.Width, _
bm.Height), GraphicsUnit.Pixel)

        g.Dispose()


      'image path. better to make this dynamic. I am hardcoding a path just for example sake
        thumb.Save("C:\newimage.bmp", _
System.Drawing.Imaging.ImageFormat.Bmp) 'can use any image format 

        bm.Dispose()

        thumb.Dispose()

        Me.Close()  'exit app
y2kshane commented: thnx for the reply :) work fine +1
Luc001 77 Posting Whiz

Hi,

You could try:

Dim str1() As String = Nothing
Luc001 77 Posting Whiz

Hi,

That's a datagridview.
For some example Images look, here.

For an explanation, look here.

Luc001 77 Posting Whiz

Hi,

You can try something like this:

TextBox1.Text = Date.Now.DayOfWeek.ToString
GeekByChoiCe commented: not what the OP wanted to know +0
Luc001 77 Posting Whiz

Hi,

Because your working with Arrays, you should use the Imports System.Collection namespace.
You can find some explanation, here.

Luc001 77 Posting Whiz

Hi,

You can do it like this:

Private Sub TextBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseDown
        TextBox1.Text = ""
    End Sub
Luc001 77 Posting Whiz

Hi,

You can try this function:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        IsPalindrome(strToCheck:=TextBox1.Text)
    End Sub

 Public Function IsPalindrome(ByVal strToCheck As String) As Boolean

        Dim iForward As Integer
        Dim iBack As Integer
        Dim iMid As Integer
        Dim bPalindrome As Boolean

        IsPalindrome = False
        bPalindrome = True
        On Error GoTo ERR_IsPalindrome

        iBack = Len(strToCheck)
        iMid = iBack / 2
        iForward = 1

        If (iBack < 1) Then
            Exit Function
        End If

        Do While (iForward <> iBack And
    iForward <= iMid)
       If (Mid(strToCheck, iForward, 1) <> Mid(strToCheck, iBack, 1)) Then
                bPalindrome = False
                MsgBox("It's not a Palindrome")
                TextBox1.Text = ""
                TextBox1.Focus()
            Else
                MsgBox("It's a palindrome")
                TextBox1.Text = ""
                TextBox1.Focus()
            End If
            Exit Do
            iBack = iBack - 1
            iForward = iForward + 1
        Loop

        IsPalindrome = bPalindrome
        Exit Function

ERR_IsPalindrome:

        Debug.Print("Error: " & Err.Description)

    End Function
Luc001 77 Posting Whiz

Hi,

If you still need more, then don't hasitate to ask them in this forum.

Don't forget to mark your thread as solved when you've got an anwser. :)