Popular Posts

Sunday, July 29, 2012

ExpandoObject Class (System.Dynamic)

Wowwww ....

Creating Object dynamically at run time, add property and functions to it and remove properties and functions .... ExpandoObject!!!!

Also enables to return anonymous type cross the libraries!!!

ExpandoObject Class (System.Dynamic):

'via Blog this'

Saturday, July 28, 2012

ASP.NET MVC 3: Layouts and Sections with Razor - ScottGu's Blog

Good example of Layouts = Masterpages by Scott Gu

ASP.NET MVC 3: Layouts and Sections with Razor - ScottGu's Blog:

'via Blog this'

Using Areas in ASP.NET MVC Application

Using areas to create same View / Model / Controller structure for each sub module of a big application. By default we can not use let is say HomeController for both Finance and HR departments. To be able to do so then we need to create Area in MVC by just right clicking on folder and then selecting add new Area...

Using Areas in ASP.NET MVC Application:

'via Blog this'

Saturday, July 14, 2012

Copy As HTML extension

visual studio addin to copy code as HTML... eg for blogs etc Install the addin, select code and right click and then Export As HTML ... That is it ... here is the output:
Code Snippet
  1.  
  2.     Private Sub SetPrivateProperty(Of t)(
  3.                                              ByVal targertObject As t,
  4.                                              ByVal targetPropertyName As String,
  5.                                              ByVal targetPropertyValue As Object
  6.                                          )
  7.         Dim type As Type = targertObject.GetType
  8.         type.InvokeMember(targetPropertyName,
  9.                           BindingFlags.NonPublic Or
  10.                           BindingFlags.SetProperty Or
  11.                           BindingFlags.Instance, Nothing,
  12.                           targertObject, New Object() {targetPropertyValue})
  13.     End Sub



Copy As HTML extension:

'via Blog this'

Code alignment

Visual studio extension that enables to do Code Alignment

Code alignment:

'via Blog this'

EF 5.x DbContext Generator for VB.NET extension

DbContext and entity generator for VB.Net

EF 5.x DbContext Generator for VB.NET extension:

'via Blog this'

Thursday, July 12, 2012

.net - Is it possible to set private property via reflection - Stack Overflow

Once the class is published then we don't have any control on how it will be used,,,, even we can set the Private or protected members of the class using refelection... see below


  Private Sub SetPrivateProperty(Of t)(
                                             ByVal targertObject As t,
                                             ByVal targetPropertyName As String,
                                             ByVal targetPropertyValue As Object
                                         )
        Dim type As Type = targertObject.GetType
        type.InvokeMember(targetPropertyName,
                          BindingFlags.NonPublic Or
                          BindingFlags.SetProperty Or
                          BindingFlags.Instance, Nothing,
                          targertObject, New Object() {targetPropertyValue})
    End Sub


.net - Is it possible to set private property via reflection - Stack Overflow:

'via Blog this'

Wednesday, July 11, 2012

How to make the treeview to scroll to a Position

I had terrible issues with treeview ... eg if you want to select a node in the bottom of the treeview and scrollbars are there then treeview does not scroll to the node ... ie does not ensure the node is visible. This code worked for me:


   Private Const SB_HORZ As Integer = &H0
    Private Const SB_VERT As Integer = &H1
    Private Sub SetTreeViewScrollPos(ByRef treeView As TreeViewByRef scrollPosition As Point)
        Try
            SetScrollPos(DirectCast(treeView.Handle, IntPtr), SB_HORZ, scrollPosition.X, True)
            SetScrollPos(DirectCast(treeView.Handle, IntPtr), SB_VERT, scrollPosition.Y, True)
            If treeView.Nodes.Count > 0 Then
                Dim currentNode As TreeNode = treeView.SelectedNode
                currentNode.EnsureVisible()
            End If
        Catch ex As Exception
 
        End Try
    End Sub
 
    <DllImport("user32.dll", CharSet:=System.Runtime.InteropServices.CharSet.Auto)> _
    Public Shared Function GetScrollPos(ByVal hWnd As IntegerByVal nBar As IntegerAs Integer
 
    End Function
    <DllImport("user32.dll")> _
    Private Shared Function SetScrollPos(ByVal hWnd As IntPtrByVal nBar As IntegerByVal nPos As IntegerByVal bRedraw As BooleanAs Integer
    End Function


Justin Davis: How to control the scrollbar position in a Tree View Control:

'via Blog this'