How to select the full row in DataGrid
2007-05-16 09:59
567 查看
How to select the full row in DataGrid?
As a multifunctional data display control, DataGrid is used frequently in practice. Sometimes, you want to select full row in datagrid which seems as follows:
Follow me, I will tell you how to present it step by step.
First, you need to specify the Data Source of the DataGrid control. then, execute a method Modify().
System.Data.DataTable dt = Oracle.GetDataTable( sql );
dataGrid1.DataSource = dt;
Modify( this.dataGrid1 ); // Note: if the datasource is null this method will throw a exception.
the code of Modify as follows:
/// <summary>
/// 移除网格列中的TextBox
/// </summary>
/// <param name="dg">数据网格控件</param>
internal void Modify( DataGrid dg )
{
DataGridTextBoxColumn x = null;
for( int i = 0; i < dg.TableStyles[ 0 ].GridColumnStyles.Count; i ++ )
{
x = dg.TableStyles[ 0 ].GridColumnStyles[ i ] as DataGridTextBoxColumn;
x.TextBox.Parent.Controls.Remove( x.TextBox );
}
}
well, you can assign the process code of CurrentCellChanged event of DataGrid now. it’s very simple.
this.dataGrid1.Select( this.dataGrid1.CurrentRowIndex );
Btw. i like Ding.
As a multifunctional data display control, DataGrid is used frequently in practice. Sometimes, you want to select full row in datagrid which seems as follows:
Follow me, I will tell you how to present it step by step.
First, you need to specify the Data Source of the DataGrid control. then, execute a method Modify().
System.Data.DataTable dt = Oracle.GetDataTable( sql );
dataGrid1.DataSource = dt;
Modify( this.dataGrid1 ); // Note: if the datasource is null this method will throw a exception.
the code of Modify as follows:
/// <summary>
/// 移除网格列中的TextBox
/// </summary>
/// <param name="dg">数据网格控件</param>
internal void Modify( DataGrid dg )
{
DataGridTextBoxColumn x = null;
for( int i = 0; i < dg.TableStyles[ 0 ].GridColumnStyles.Count; i ++ )
{
x = dg.TableStyles[ 0 ].GridColumnStyles[ i ] as DataGridTextBoxColumn;
x.TextBox.Parent.Controls.Remove( x.TextBox );
}
}
well, you can assign the process code of CurrentCellChanged event of DataGrid now. it’s very simple.
this.dataGrid1.Select( this.dataGrid1.CurrentRowIndex );
Btw. i like Ding.
相关文章推荐
- How to select the first/least/max row per group in SQL
- what is the difference of select single and select up to one row in abap
- How to Capture the Row Selected on Search Page In a Variable?
- How to collect the full path name of the files in ASM diskgroups (文档 ID 888943.1)
- How to make two <div>…</div> in the same row?
- flex/in the datagrid,how to get the new value of cell in the datagrid after edit
- How to collect the full path name of the files in ASM diskgroups (文档 ID 888943.1)
- [转]WinForms GridListEditor - How to restore values in the auto filter row
- How to set up OpenERP for various timezone kindly follow the following steps to select timezone in OpenERP
- How to select the data type in SQLserver database such as varchar, nvarchar
- How to fullscreen the video in nw fullscreen status
- How to share text to Message in the app you are building(iOS platform)
- How to determine the size of a class/struct in the C++?
- How to Switch the Driving Table in a Hash Join (文档 ID 171940.1)
- How to tell if you’re running the 32 bit or 64 bit kernel in Mac OS X Snow Leopard
- How to save the currently edited row without moving to another row
- How to Increase the Memory Limit for 32-bit Applications in Windows 64-bit OS
- quick select to find the kth smallest element in array
- How to detect when the mouse move away from a TPanel in Delphi ?
- How to Use `strace` to Trace the System Call in Linux