View previous topic :: View next topic |
Author |
Message |
cpbird
Joined: 29 Mar 2011 Posts: 4
|
Posted: Fri Apr 29, 2011 9:50 am Post subject: about tree_GetRowData |
|
|
Follow the code:
private void tree_GetRowData(object sender, GetRowDataEventArgs e)
{
RowBinding binding = tree.GetRowBinding(e.Row);
binding.GetRowData(e.Row, e.RowData);
..........
}
I want to know the red cod what to do. If I remove the red code ,what influence will be caused? |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Sat Apr 30, 2011 12:01 am Post subject: |
|
|
Is this code from a sample?
The code is getting the design time RowBinding associated with the given row and using it to set the default RowData properties. This is a common approach if you are using design time Object Binding or DataSet Binding and just want to override the binding settings for a specific row.
If you are not using design time binding then you shouldn't do this - because tree.GetRowBinding will return null and the next line will fail. _________________ Infralution Support |
|
Back to top |
|
|
cpbird
Joined: 29 Mar 2011 Posts: 4
|
Posted: Sat Apr 30, 2011 9:03 am Post subject: |
|
|
Fellow the code:
private void tree_GetRowData(object sender, GetRowDataEventArgs e)
{
RowBinding binding = tree.GetRowBinding(e.Row);
binding.GetRowData(e.Row, e.RowData);
if (e.Row.Item != null)
{
DSCPLMain.epcProjectVariantRow variantRow = e.Row.Item as DSCPLMain.epcProjectVariantRow;
if (variantRow != null)
{
if (!variantRow.IsIsPBMNull() && variantRow.IsPBM == 1)
{
e.RowData.OddStyle = new Style(e.RowData.OddStyle, pbmVariantRowStyle);
e.RowData.EvenStyle = new Style(e.RowData.OddStyle, pbmVariantRowStyle);
}
}
}
}
Through debug,I found that,whatever the 'binding.GetRowData(e.Row, e.RowData);' run, the 'e.Row.Item ' still has data.
I think that if the code 'binding.GetRowData(e.Row, e.RowData);' can be removed. Because that is time-consuming. |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Mon May 02, 2011 12:36 am Post subject: |
|
|
The GetRowData event is used to set the Icon and style for the row. If you don't set these (either programmatically or by calling the binding.GetRowData method) then you just get the default style and no icon. If you remove this and it doesn't affect the look of your tree then you don't need it. _________________ Infralution Support |
|
Back to top |
|
|
|