Search This Blog

Tuesday, January 22, 2013

Stop Statement (VB.NET)

VB.Net > StatementsStop

Stop is a programmatic alternative to setting a breakpoint and suspends the execution. When the debugger finds Stop statement, it breaks execution of the program.

Note: Unlike End, it does not close any files or clear any variables.

Example:

Dim i As Integer
Dim j As Integer
For i = 1 To 100
 j = i + 1
 Stop
Next i







With...End With Statement (VB.NET)

VB.NET > Statements > With...End With

Executes a series of statements that repeatedly refers to a single object or structure.

By using With...End With, you can perform a series of statements on a specified object without specifying the name of the object multiple times.

Example:


Public Class Form1
  Private Class Customer
    Public Property Id As String
    Public Property Name As String
  End Class
  Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    With New Customer
      .Id = 1
      .Name = "Elsoft"
      MessageBox.Show(.Name)
    End With
  End Sub




Monday, January 21, 2013

Temporary Tables (SQL Server)

SQL Server > Temporary tables

Local temporary tables
  • visible only to their creators during the same connection to an instance of SQL Server
  • deleted after the user disconnects from the instance of SQL Server
  • local temporary table name is stared with hash ("#") sign.
Example

Create temporary table

    Global temporary tables

    • visible to any user and any connection after they are created
    • deleted when all users that are referencing the table disconnect from the instance of SQL Server
    • global Temporary tables name starts with a double hash ("##")





    Get parent row RadGridView Telerik

    Telerik > Windows Forms > Get parent row RadGridView

    Example: Get parent row RadGridView Telerik

    Dim oParentRow As GridViewDataRowInfo = grd.CurrentRow.ViewInfo.ParentRow








    Terminate application (VB.Net)

    VB.NET > Statements > End

    End  force the application to stop running.
    • closes files opened Open statement
    • clears all the application variables

    Example:

    End application on button click

    Public Class Form1

        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        End Sub

        Private Sub btn_Click(sender As Object, e As EventArgs) Handles btn.Click
            If MsgBox("Do you want to exit?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
                End
            End If
        End Sub

    End Class




    Wednesday, January 16, 2013

    Disable ContextMenu RadGridView Telerik

    Telerik > Windows Forms > Disable ContextMenu RadGridView

    AllowColumnHeaderContextMenu: Gets or sets a value indicating whether context menu is displayed when user right clicks on a data cell.
    AllowCellContextMenu: Gets or sets a value indicating whether context menu is displayed when user right clicks on a data cell.

    Example: Disable ContextMenu RadGridView Telerik

    RadGridView1.MasterTemplate.AllowColumnHeaderContextMenu = False
    RadGridView1.MasterTemplate.AllowCellContextMenu = False





    WPF CheckBox Control (C#)

    CheckBox enables the user to select whether an option is on or off.

    XAML:


    <Window x:Class="WpfApplication1.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="MainWindow" Height="350" Width="525">
        <Grid>
            <CheckBox Content="CheckBox" Height="16" HorizontalAlignment="Left" Margin="10,10,0,0" Name="checkBox1" VerticalAlignment="Top" Checked="checkBox1_Checked" Unchecked="checkBox1_Unchecked" />
            <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="12,32,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" />
        </Grid>
    </Window>

    C# code behind:


     private void checkBox1_Checked(object sender, RoutedEventArgs e)
            {
                    MessageBox.Show("checkBox1 Checked");
            }
            private void checkBox1_Unchecked(object sender, RoutedEventArgs e)
            {
                  MessageBox.Show("checkBox1 UnChecked");
            }
            private void button1_Click(object sender, RoutedEventArgs e)
            {
                if (checkBox1.IsChecked == true)
                    MessageBox.Show("checkBox1 Checked");
                else
                    MessageBox.Show("checkBox1 UnChecked");
            }

    Runtime: