Keep up with our latest news and site updates

Subscribe Via RSS Reader

Powered by

- 간단한 데이터 바인딩 방법
- BindingComplete 이벤트를 구현하여 바인딩 정보를 분석하여 바인딩 데이터를 가공하는 방법
- BindingComplete 이벤트의 호출 상황을 분석하여 바인딩이 실행되는 흐름을 파악하고, 효율적인 바인딩을 구현하는 방법

BindingComplete 이벤트 구현 예제

    TRANSFORMERBindingSource.BindingComplete +=
    	new BindingCompleteEventHandler(TRANSFORMERBindingSource_BindingComplete);
 
void TRANSFORMERBindingSource_BindingComplete (
	object sender,
	BindingCompleteEventArgs e)
{
    if ( e.BindingCompleteState == BindingCompleteState.Success
    	&& e.BindingCompleteContext == BindingCompleteContext.DataSourceUpdate )
	{
        string columnname = e.Binding.BindingMemberInfo.BindingMember;
        TransformerDataSet.TRANSFORMERRow datasource
			= (TRANSFORMERBindingSource.Current as DataRowView).Row
        	as TransformerDataSet.TRANSFORMERRow;
        string controlname = e.Binding.Control.Name;
 
        MessageBox.Show(
	        controlname + "->" + "["
	        + columnname + " / "
	        + datasource[columnname] + "]");
    }
 
    if ( e.BindingCompleteState == BindingCompleteState.Success
    	&& e.BindingCompleteContext == BindingCompleteContext.ControlUpdate
    	&& e.Binding.Control == ConnectivityNodeNameEdit2 )
	{
        string controlname = e.Binding.Control.Name;
        string columnname = e.Binding.BindingMemberInfo.BindingMember;
        BindingSource bindingsource = e.Binding.DataSource as BindingSource;
 
        if ( bindingsource != null && !(bindingsource.Position < 0) )
		{
            TransformerDataSet.TRANSFORMERRow datasource
            	= (bindingsource.Current as DataRowView).Row
            	as TransformerDataSet.TRANSFORMERRow;
            MessageBox.Show("["
            	+ columnname + "/"
            	+ datasource[columnname] + "] ->"
            	+ controlname);
        } else {
            MessageBox.Show("Invalid : " + columnname + "/" + controlname);
        }
    }
 
    if ( e.BindingCompleteState == BindingCompleteState.Success
    	&& e.BindingCompleteContext == BindingCompleteContext.ControlUpdate
    	&& e.Binding.Control == fK_CONNECTIVITYNODE2SpinEdit )
	{
        string controlname = e.Binding.Control.Name;
        string columnname = e.Binding.BindingMemberInfo.BindingMember;
        BindingSource bindingsource = e.Binding.DataSource as BindingSource;
 
        if ( bindingsource != null && !(bindingsource.Position < 0) )
        {
            TransformerDataSet.TRANSFORMERRow datasource
            	= (bindingsource.Current as DataRowView).Row
            	as TransformerDataSet.TRANSFORMERRow;
            MessageBox.Show("["
            	+ columnname + "/"
            	+ datasource[columnname] + "] ->" + controlname);
        } else {
            MessageBox.Show("Invalid : " + columnname + "/" + controlname);
        }
    }
 
    if ( e.BindingCompleteState == BindingCompleteState.Success
    	&& e.BindingCompleteContext == BindingCompleteContext.ControlUpdate
    	&& e.Binding.Control == ConnectivityNodeNameEdit1 )
	{
        string controlname = e.Binding.Control.Name;
        string columnname = e.Binding.BindingMemberInfo.BindingMember;
        BindingSource bindingsource = e.Binding.DataSource as BindingSource;
 
        if ( bindingsource != null && !(bindingsource.Position < 0) )
        {
            TransformerDataSet.TRANSFORMERRow datasource
            	= (bindingsource.Current as DataRowView).Row
            	as TransformerDataSet.TRANSFORMERRow;
            MessageBox.Show("["
            	+ columnname + "/"
            	+ datasource[columnname] + "] ->"
            	+ controlname);
        } else {
            MessageBox.Show("Invalid : " + columnname + "/" + controlname);
        }
    }
 
    if ( e.BindingCompleteState == BindingCompleteState.Success
    	&& e.BindingCompleteContext == BindingCompleteContext.ControlUpdate
    	&& e.Binding.Control == fK_CONNECTIVITYNODE1SpinEdit )
	{
        string controlname = e.Binding.Control.Name;
        string columnname = e.Binding.BindingMemberInfo.BindingMember;
        BindingSource bindingsource = e.Binding.DataSource as BindingSource;
 
        if ( bindingsource != null && !(bindingsource.Position < 0) )
        {
            TransformerDataSet.TRANSFORMERRow datasource
            	= (bindingsource.Current as DataRowView).Row
            	as TransformerDataSet.TRANSFORMERRow;
            MessageBox.Show("["
            	+ columnname + "/"
            	+ datasource[columnname] + "] ->"
            	+ controlname);
        } else {
            MessageBox.Show("Invalid : " + columnname + "/" + controlname);
        }
    }
}

Related Tags: [ , , ]

Information

Encore Subtitle, Tokyo, Osaka, Kyoto, Mac, iPhone, .NET, Microsoft Windows, Programming, Journey, Tips, Useful Information, TextEdit Plugin, Detective, Universal Reader, Universal Detector, Movist, SIMBL, Delphi
© 2008 Mac and PC life stories by maidaro All Rights Reserved.
An antisocialmediallc.com variation of Projection Template from Template World