- Visual C# 2005 Keyboard Shortcut Reference Poster (MS Downloads)
- LINQ to SQL (Ben Hall)
- ReSharper 4 (JetBrains)
- Silverlight 2 (dzone)
- Design Patterns (dzone)
- Design Patterns (Jason McDonald)
- UML (Laurent Grégoire)
- UML (Allen Holub)
- JavaScript (Dave Child)
- jQuery Selectors (dzone)
- Getting Started with AJAX (dzone)
- MS AJAX (Jay Kimble)
- CSS (Leslie Franke)
- SQL Server (Dave Child)
- SQL Server 2005 (Simon Sheppard)
- SQL Injection (Ferruh Mavituna)
- VIM Quick Reference Card (Laurent Grégoire)
- Regular Expressions (Dave Child)
- Regular Expressions (.NET) (regexlib)
- Firefox (Leslie Franke)
- TFS Command Line (TF.exe) (Noah Coad)
- SVN (Ariejan de Vroom)
- Google Search (Nancy Blachman, Tasha Bergson-Michelson, & Jerry Peek)
- Windows XP Command Line (Simon Sheppard)
- SEO (seomoz)
- Gimp (ozh)
- Photoshop (Multiple Versions) (Trevor Morris)
- VB.NET/C# Comparison
- Microsoft .NET Framework 3.5 Commonly Uses Types and Namespaces (PDF)
- RGB Hex Color Chart
- Visual Studio 2005 Default Keybindings C# | VB (PDF)
- Visual Studio 2008 Default Keybindings C# | VB
- Microsoft ASP.NET AJAX Library
- Microsoft ASP.NET AJAX Client Life Cycle & Events (PDF)
- .NET Format String Quick Reference (PDF)
Tuesday, July 8, 2008
Tài liệu tham khảo nhanh dành cho .NET Developer
Cách thiết lập focus cho một control khác sau khi sử lý sự kiện AfterSelect của TreeView
TreeView control có thể gây cho bạn khó khăn trong trường hợp này, nó cập nhật lại Node được lựa chọn và thực hiện focus trở lại Node này sau khi xử lý sự kiện. Cách thực hiện cho trường hợp này là làm trễ việc thực thi đoạn code của bạn cho đến khi hoàn thành việc xử lý sự kiện trên control TreeView. Dưới đây là sample cho việc xử lý trường hợp này:
private delegate void FocusAfterSelect(TreeNode node);
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
this.BeginInvoke(new FocusAfterSelect(HandleAfterSelect), e.Node);
}
private void HandleAfterSelect(TreeNode node)
{
textBox1.Text = node.Text;
textBox1.Focus();
}
Monday, July 7, 2008
Truy cập các phương thức private sử dụng Reflection trong .NET.
Để truy cập vào các phương thức hoặc thuộc tính private của một lớp, ta sẽ sử dụng gói Reflection được xây dựng bên trong .NET Framework. Để minh họa cho khả năng của của Reflection trong .NET Framework, tôi xin đưa ra một ví dụ bên dưới:
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
namespace ReflectionSamples
{
public class ReflectionSample
{
private void Method1()
{
Console.WriteLine("Method 1 called");
}
private int Method2(int x, int y)
{
Console.WriteLine("Method 2 called {0}, {1}", x, y);
return x*y;
}
internal string RedAlert
{
get
{
Console.WriteLine("Red Alert");
return "Red Alert";
}
}
}
internal class Program
{
private static void Main(string[] args)
{
//Tạo instance của lớp mà ta sẽ thực hiện truy cập các hàm private
MyClass instance = new MyClass();
//Get Type of class
Type t = typeof (MyClass);
//Lấy thông tin của phương thức Method1
MethodInfo method1 = t.GetMethod("Method1",
BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod);
//Gọi phương thức trên đối tượng được tham chiếu bằng instance và truyền tham số
method1.Invoke(instance, null);
//Truy cập thông tin của Properties
PropertyInfo property = t.GetProperty("RedAlert",
BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetProperty);
//Gọi Properties tương ứng và truyền tham số
string str = (string)property.GetValue(instance, null);
//Truy cập thông tin của phương thức Method2
MethodInfo method2 = t.GetMethod("Method2",
BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod);
//Gọi phương thức và truyền 2 tham số (các tham số được truyền thông qua danh sách đối tượng
object o = method2.Invoke(instance, new object[] {2, 3});
//Với trường hợp phương thức có giá trị trả lại
if (o != null)
{
Console.WriteLine("Method 2 returned: " + o.ToString());
}
Console.ReadKey();
}
}
}
Subscribe to:
Posts (Atom)