Archive for the ‘Uncategorized’ Category
How to Extract SQL EXPRESS Installer
Posted by: admin in Uncategorized on June 18th, 2010
To extract the sql express edition use,
1. Goto Command prompt
2. navigate to the sqlexpr32.exe
3. Type sqlexpr32.exe /x
Error exporting data to UTF8 in SQL Server DTS
Posted by: admin in Uncategorized on June 16th, 2010
Error 0×00470d4: Data Flow Task 1: The code page on input column “COLUMN_NAME” (111) is 1252 and is required to be 65001.
(SQL Server Import and Export Wizard)
Usually this error appears when the table has a data type of VARCHAR, what you need to do is to change it NVARCHAR.
How to Create Line Number
Posted by: admin in Uncategorized on April 1st, 2009
This article demonstrates how to add line numbers to a rich text box control. This is done by adding a picture box control on the left side of the rich text box control. When the appropriate events happen on the Form or on the RichTextBox control we call a method that paints the line numbers on the PictureBox control. This approach is more accurate and efficient than other approaches I’ve seen where another textbox control was used for printing the line numbers. The PictureBox will only print the line numbers that are currently visible in the RichTextBox control.
During the process of constructing this code sample, I initially based it on the code sample provided in the article http://www.codeproject.com/cs/miscctrl/numberedtextbox.asp and enhanced it by doing the following:
- Replace the Label control for numbering with a PictureBox
- I fixed the scrolling problem with that implementation due to the fact that RichTextBox uses smooth scrolling (scrolling with the scrollbar scrolls the text in pixels, not in lines), as a result sometimes the first line may be displayed in half, at which case the line numbering should address it.
Here is the code for printing the line numbers. Note that we have a RichTextBox control
called MyRichTextBox and a PictureBox control called MyPictureBox. The method gets one
argument which is the Graphics of the PictureBox control.
This is the method DrawRichTextBoxLineNumbers:
-
Private Sub DrawRichTextBoxLineNumbers(ByRef g As Graphics)
-
-
'Calculate font heigth as the difference in Y coordinate
-
-
'between line 2 and line 1
-
-
'Note that the RichTextBox text must have at least two lines.
-
-
' So the initial Text property of the RichTextBox
-
-
' should not be an empty string. It could be something
-
-
' like vbcrlf & vbcrlf & vbcrlf
-
-
With MyRichTextBox
-
-
Dim font_height As Single
-
-
font_height = .GetPositionFromCharIndex(.GetFirstCharIndexFromLine(2)).Y _
-
-
- .GetPositionFromCharIndex(.GetFirstCharIndexFromLine(1)).Y
-
-
If font_height = 0 Then Exit Sub
-
-
'Get the first line index and location
-
-
Dim first_index As Integer
-
-
Dim first_line As Integer
-
-
Dim first_line_y As Integer
-
-
first_index = .GetCharIndexFromPosition(New _
-
-
Point(0, g.VisibleClipBounds.Y + font_height / 3))
-
-
first_line = .GetLineFromCharIndex(first_index)
-
-
first_line_y = .GetPositionFromCharIndex(first_index).Y
-
-
'Print on the PictureBox the visible line numbers of the RichTextBox
-
-
g.Clear(Control.DefaultBackColor)
-
-
Dim i As Integer = first_line
-
-
Dim y As Single
-
-
Do While y < g.VisibleClipBounds.Y + g.VisibleClipBounds.Height
-
-
y = first_line_y + 2 + font_height * (i - first_line - 1)
-
-
g.DrawString((i).ToString, .Font, Brushes.DarkBlue, MyPictureBox.Width _
-
-
- g.MeasureString((i).ToString, .Font).Width, y)
-
-
i += 1
-
-
Loop
-
-
'Debug.WriteLine("Finished: " & firstLine + 1 & " " & i - 1)
-
-
End With
-
-
End Sub
-
-
Private Sub r_Resize(ByVal sender As Object, ByVal e As System.EventArgs) _Handles MyRichTextBox.Resize
-
DrawRichTextBoxLineNumbers(Me.MyPictureBox.CreateGraphics)
-
MyPictureBox.Invalidate()
-
-
End Sub
-
-
Private Sub r_VScroll(ByVal sender As Object, ByVal e As System.EventArgs) _
-
Handles MyRichTextBox.VScroll
-
DrawRichTextBoxLineNumbers(Me.MyPictureBox.CreateGraphics)
-
MyPictureBox.Invalidate()
-
End Sub
-
-
Private Sub p_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) _
-
Handles MyPictureBox.Paint
-
DrawRichTextBoxLineNumbers(e.Graphics)
-
End Sub
-
-
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
-
-
Handles MyBase.Load
-
-
MyRichTextBox.Text = vbCrLf & vbCrLf & vbCrLf
-
-
End Sub
Source: Line Numbering of RichTextBox in .NET 2.0
How to Load Bitmap into the Picturebox
Posted by: admin in Uncategorized on March 16th, 2009
mports System
Imports System.Collections
Imports System.Data
Imports System.IO
Imports System.Xml.Serialization
Imports System.Windows.Forms
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Drawing.Text
Imports System.Drawing.Printing
Private sub LoadBitmapImage()
Me.PictureBox1.Image = New System.Drawing.Bitmap(”c:\mypic.bmp”)
End Sub
MDI - Close All Forms
Posted by: admin in Uncategorized on February 11th, 2009
Private Sub CloseAll()
For Each f As Form In Me.MdiChildren
f.close()
Next
End Form
How to lock folder
Posted by: admin in Uncategorized on February 5th, 2009
If you want to lock your folder. Follow the simple instruction, let’s say you want to lock the folder SEXY folder.
1. Open Notepad and type the following
ren SEXY SEXY.{21EC2020-3AEA-1069-A2DD-08002B30309D}
Save the text file as lock.bat in the same level of SEXY folder.
2. Open another new Notepad and type the following
ren SEXY.{21EC2020-3AEA-1069-A2DD-08002B30309D}
3. Save the text file as unlock.bat in the same drive.
How to use:
1. To lock the pics folder, simply click the lock.bat and it will transform into control panel icon which is inaccessible.
2. To unlock the folder click the unlock.bat file. Thus the folder will be unlocked and the contents are accessible.
For more tips & tricks visit: http://techytonic.blogspot.com/2008/03/lock-folder-using-notepad.html