Thursday, November 27, 2008

C# .NET force control to refresh programatically

public partial class MainWindow : Form
{
List _latestPriceList = new List();
public MainWindow ()
{
    InitializeComponent();
    

    // Set the DataSource property of the ListBox called priceListBox1
    priceListBox1.DataSource = _latestPriceList;
}

}


private void AddNewPrice(double newprice)
{
    // Insert the string at the front of the List.
    _latestPriceList.Insert(0, newprice);

    // Force a refresh of the ListBox.
         ((CurrencyManager)priceListBox1.BindingContext[_latestPriceList]).Refresh();
}

Thursday, November 06, 2008

How to disable MSN Messenger on XP

It's very annoying that MSN Messenger loaded when window starts. This is how you can get rid of it.

Save the following text as DisableMSN.reg. Double click and run the content. Done.

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Messenger]

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Messenger\Client]
"PreventRun"=dword:00000001

Wednesday, November 05, 2008

How to make asp.net textbox readonly

A asp.net2 textbox control will not perform any postback if the readonly is set to true. Thus, no validation could be performed if required.

Why not setting the atttribute client side? This disables the user from editing the value. Moreover, it supports post back. Cool. :)

// Make the textbox readonly at client side
txbDailyAllowance.Attributes.Add("readonly", "readonly");

Tuesday, November 04, 2008

Oracle PLSQL Cursor Example

DECLARE

CURSOR c_emp (p_dept VARCHAR2) IS
SELECT ename, salary
FROM emp
WHERE deptno = p_dept
ORDER BY ename;

r_dept DEPT%ROWTYPE;

BEGIN

OPEN c_emp (r_dept.deptno);
LOOP
FETCH c_emp INTO v_ename, v_salary;
EXIT WHEN c_emp%NOTFOUND;

END LOOP;
CLOSE c_emp;

END;