3/30/11

textbox validation only for NUMBERS

If (Microsoft.VisualBasic.Asc(e.KeyChar) < 48) Or (Microsoft.VisualBasic.Asc(e.KeyChar) > 57) Then e.Handled = True End If If (Microsoft.VisualBasic.Asc(e.KeyChar) = 8) Then e.Handled = False End If

textbox validation only for charachters-WINDOWS

Private Sub TextBox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox3.KeyPress If (Microsoft.VisualBasic.Asc(e.KeyChar) < 65) _ Or (Microsoft.VisualBasic.Asc(e.KeyChar) > 90) _ And (Microsoft.VisualBasic.Asc(e.KeyChar) < 97) _ Or (Microsoft.VisualBasic.Asc(e.KeyChar) > 122) Then If (Microsoft.VisualBasic.Asc(e.KeyChar) <> 32) Then e.Handled = True End If End If ' Allowed backspace If (Microsoft.VisualBasic.Asc(e.KeyChar) = 8) Then e.Handled = False End If 'Allowed space End Sub

3/27/11

messagebox in C#

There is no class like System.Windows.Form in C#....... as i want to use messagebox in C# I have added reference as In solution explorer -> right click to website add refenrence -> system.windows.forms check checkbox write in program i.e. default.aspx using system.windows.forms; //add lib use messagebox("Hello");

3/14/11

What is the .NET Framework?

What is the .NET Framework? The Microsoft .NET Framework is a platform for building, deploying, and running Web Services and applications. It provides a highly productive, standards-based, multi-language environment for integrating existing investments with next-generation applications and services as well as the agility to solve the challenges of deployment and operation of Internet-scale applications. The .NET Framework consists of three main parts: the common language runtime, a hierarchical set of unified class libraries, and a componentized version of Active Server Pages called ASP.NET.

3/2/11

DataGridViewRow cell click

Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick Dim r As New DataGridViewRow If DataGridView1.Rows.Count > 0 Then r = DataGridView1.Rows(e.RowIndex) TextBox1.Text = r.Cells(0).Value TextBox2.Text = r.Cells(1).Value TextBox3.Text = r.Cells(2).Value price.Text = r.Cells(3).Value / r.Cells(2).Value End If End Sub

Save Data Grid Data

If DataGridView1.Rows.Count > 0 Then Dim r As DataGridViewRow For Each r In DataGridView1.Rows Dim db As New DBAccess Dim strSQL As String strSQL = "INSERT INTO [dbo].[Table_2] ([name1] ,[id1]) VALUES ( '" & r.Cells(0).Value & "'," & r.Cells(3).Value & " )" db.ExecuteScalar(strSQL, Data.CommandType.Text) db.CloseDB() Next End If

color tree node on specific condition

color tree node on specific condition Private Sub Form5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load TreeView1.Nodes.Add("222") TreeView1.Nodes(0).Nodes.Add("ABC12") TreeView1.Nodes(0).Nodes.Add("ABC13") TreeView1.Nodes(0).Nodes.Add("ABC14") TreeView1.Nodes(0).Nodes(0).Nodes.Add("ABC121") TreeView1.Nodes(0).Nodes(0).Nodes(0).Nodes.Add("ABC122") TreeView1.Nodes(0).Nodes(0).Nodes(0).Nodes(0).Nodes.Add("222") TreeView1.Nodes(0).Nodes(0).Nodes(0).Nodes.Add("333") TreeView1.Nodes(0).Nodes(0).Nodes.Add("ABC123") TreeView1.Nodes(0).Nodes(1).Nodes.Add("ABC131") TreeView1.Nodes(0).Nodes(1).Nodes(0).Nodes.Add("222") TreeView1.Nodes(0).Nodes(2).Nodes.Add("ABC121") TreeView1.Nodes(0).Nodes(2).Nodes.Add("111") TreeView1.Nodes(0).Nodes.Add("222") TreeView1.ExpandAll() If TreeView1.Nodes.Count > 0 Then For Each tnode As TreeNode In TreeView1.Nodes nodechk(tnode) Next End If End Sub Sub nodechk(ByVal m11 As TreeNode) apply(m11) If m11.Nodes.Count > 0 Then For Each m1 In m11.Nodes nodechk(m1) Next End If End Sub Sub apply(ByVal m1 As TreeNode) If m1.Text = "ABC121" Then m1.BackColor = Color.OrangeRed m1.ForeColor = Color.White Dim f As Font = New Font("verdana", 9, FontStyle.Bold) m1.NodeFont = f End If If m1.Text = "222" Then m1.BackColor = Color.Green m1.ForeColor = Color.White Dim f As Font = New Font("verdana", 9, FontStyle.Bold) m1.NodeFont = f End If End Sub

On textbox key down /focus help shd open

Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown If e.KeyCode = Keys.F1 Then Panel1.Visible = True TextBox1.Enabled = False TextBox2.Focus() End If End Sub Private Sub TextBox2_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox2.Leave If TextBox2.Text <> "" Then Panel1.Visible = False TextBox1.Enabled = True TextBox1.Text = TextBox2.Text End If End Sub