Sunday, 26 February 2012

sending TAB key in WPF


 public static void Enter_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                e.Handled = true;
                KeyEventArgs eInsertBack = new KeyEventArgs(Keyboard.PrimaryDevice, Keyboard.PrimaryDevice.ActiveSource, 0, Key.Tab);
                eInsertBack.RoutedEvent = UIElement.KeyDownEvent;
                InputManager.Current.ProcessInput(eInsertBack);
            }
        }

Sunday, 27 November 2011

how to sum a column in datatable

If untyped (replace int with the correct data type):
 var sum = table.AsEnumerable().Sum(x=>x.Field<int>(3));
or:
 var sum = table.AsEnumerable().Sum(x=>x.Field<int>("SomeProperty"));
If typed:
 var sum = table.Sum(x=>x.SomeProperty);

Wednesday, 9 November 2011

Sending Key or simulation Key press

 if (e.Key == Key.Down)
        {
            e.Handled = true;
            KeyEventArgs eInsertBack = new KeyEventArgs(Keyboard.PrimaryDevice, 
 Keyboard.PrimaryDevice.ActiveSource, 0, Key.Tab);
            eInsertBack.RoutedEvent = UIElement.KeyDownEvent;
            InputManager.Current.ProcessInput(eInsertBack);
        }

Tab order not working in WPF

<TabControl TabIndex="4" KeyboardNavigation.TabNavigation="Local">

Tuesday, 8 November 2011

How to run WPF - XBAP as Full Trust Application

How to run WPF - XBAP as Full Trust Application

Recently I work on WPF-XBAP application that will run from intranet website:

Monday, 3 October 2011

Right Align text in SQL Server

CREATE FUNCTION PadLeft(@PadString nvarchar(100), @PadLength int)
RETURNS nvarchar(200)
AS
begin
return  replicate(' ',@padlength-len(@PadString)) + @PadStringend
goprint dbo.PadLeft('123.456', 20)
print dbo.PadLeft('1.23', 20)