Search This Blog

Thursday, June 27, 2013

CREATE TABLE SQL Server

SQL Server SQL Statements > CREATE TABLE

CREATE TABLE statement creates a table in a database.

Syntax

CREATE TABLE table_name
(
   column_name data_type(size),
   ...
);

Example

CREATE TABLE [dbo].[Table1](
       [ID] [bigint] IDENTITY(1,1) NOT NULL,
       [Name] [nvarchar](50) NOT NULL,
       [Password] [nvarchar](50) NOT NULL,
 CONSTRAINT [PK_users1] PRIMARY KEY CLUSTERED
(
       [ID] ASC
)
) ON [PRIMARY]
GO




Tuesday, June 25, 2013

Putting Quotation Marks in a String C#

C# > String > Quote

const string quote = "\"";
string str = "Topic: " + quote + "Putting Quotation Marks in a String" + quote;






Monday, June 3, 2013

Disable Spin Editor GridViewDecimalColumn RadGridView

Telerik > Windows Forms > > RadGridView > Disable Spin Editor


GridSpinEditor represents a spin editor in RadGridView.

Example: How to disable GridSpinEditor in RadGridView

  Private Sub RadGrid_CellEditorInitialized(sender As Object, e As Telerik.WinControls.UI.GridViewCellEventArgs) Handles Me.CellEditorInitialized
        Dim spinEditor As GridSpinEditor = TryCast(Me.ActiveEditor, GridSpinEditor)
        If spinEditor IsNot Nothing Then
            Dim element As GridSpinEditorElement = spinEditor.EditorElement
            element.ShowUpDownButtons = False
            element.InterceptArrowKeys = False
            element.EnableMouseWheel = False
        End If
    End Sub





Arrow keys not trigger VB NET

VB.NET > Form > Methods > ProcessCmdKey

ProcessCmdKey method processes a command key.

Example:
Use ProcessCmdKey to catch arrow keys (arrow keys not trigger VB NET in form events)

Solution:
   
Protected Overrides Function ProcessCmdKey(ByRef msg As Message, ByVal keydata As Keys) As Boolean
        If keydata = Keys.Right Or keydata = Keys.Left Or keydata = Keys.Up Or keydata = Keys.Down Then
            OnKeyDown(New KeyEventArgs(keydata))
            ProcessCmdKey = True
        Else
            ProcessCmdKey = MyBase.ProcessCmdKey(msg, keydata)
        End If
    End Function

Private Sub RunForm_KeyDown(sender As System.Object, e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
        If e.KeyCode = Keys.Right Then
        End If
End Sub

 






Monday, April 22, 2013

Numeric Column DataGridView c#

C# DataGridView > Numeric Column

EditingControlShowing event occurs when a control for editing a cell is showing.

Example


         private void dataGridView1_EditingControlShowing(object sender,                  DataGridViewEditingControlShowingEventArgs e)
        {
            e.Control.KeyPress -= new KeyPressEventHandler(NumColumn_KeyPress);
            if (dataGridView1.CurrentCell.ColumnIndex == 2 || dataGridView1.CurrentCell.ColumnIndex == 3) // numeric columns
            {
                TextBox tb = e.Control as TextBox;
                if (tb != null)
                {
                    tb.KeyPress += new KeyPressEventHandler(NumColumn_KeyPress);
                }
            }
        }
        private void NumColumn_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!char.IsControl(e.KeyChar)
                && !char.IsDigit(e.KeyChar) && !char.IsPunctuation(e.KeyChar) )
            {
                e.Handled = true;
            }


        }





Thursday, April 4, 2013

PlusMinus buttons visible RadTreeview Telerik

Telerik > Windows Forms > PlusMinus buttons visible RadTreeview Telerik

ExpanderElement: Gets the property grid item expander element.

Example: PlusMinus buttons visible RadTreeview Telerik 

Private Sub tv_NodeFormatting(sender As System.Object, e As Telerik.WinControls.UI.TreeNodeFormattingEventArgs) Handles tvArbore.NodeFormatting

If e.Node.BackColor.Name <> "LightBlue" Then
     e.NodeElement.ExpanderElement.Visibility = Telerik.WinControls.ElementVisibility.Hidden
Else
     e.NodeElement.ExpanderElement.Visibility = Telerik.WinControls.ElementVisibility.Visible
End If

End Sub

 





Tuesday, April 2, 2013

Finding columns of SQL Server temporary table

SQL Server > Catalog Views > sys.columns

Retrieve info about columns of an object that has columns,.

Example

Finding columns of SQL Server temporary table

select
  *
FROM
  tempdb.sys.columns
WHERE
 [object_id] = OBJECT_ID('tempdb..##MyGlobalTemp')