собственно сабж — как можно встроить в ультрагрид тривью,
так чтобы при нажатии на комбобокс отображалось тривью а не список?
Re: Infragistics UltraGrid - вместо combobox - treeview
От:
Аноним
Дата:
06.09.06 14:43
Оценка:
Здравствуйте, VanoTech, Вы писали:
VT>собственно сабж — как можно встроить в ультрагрид тривью, VT>так чтобы при нажатии на комбобокс отображалось тривью а не список?
В NetAdvantage 2005/3 вроде нельзя. Если нужно не совсем дерево, а просто
иерархическое отображение данных (по какому-то критерию),
то можно унаследоваться от UltraCombo и через DrawFilter повлиять на отрисовку.
Например тут отрисовываются со смещением item's с ":":
'''<summary>Method draws all rows from drawParams.Element.ChildElements</summary>
'''<param name="drawPhase">Indicates in which drawPhase this function was called.
''' We use "Infragistics.Win.DrawPhase.BeforeDrawElement" phase
''' </param>
'''<param name="drawParams">Contains elements to draw with Graphics</param>
'''<returns>True, that indicates, that no default drawing is necessary
''' </returns>
Private Function DrawElement(ByVal drawPhase As Infragistics.Win.DrawPhase, ByRef drawParams As Infragistics.Win.UIElementDrawParams) As Boolean Implements Infragistics.Win.IUIElementDrawFilter.DrawElement
' declare child UIElement used to loop through UIElement collection
Dim uieChild As Infragistics.Win.UIElement
' declare row UIElement used to referent the found row
Dim uieRow As Infragistics.Win.UltraWinGrid.RowUIElement
Dim textFont As System.Drawing.Font = Me.Textbox.Font
Dim foreColor As System.Drawing.Brush = New System.Drawing.SolidBrush(Color.Black)
Dim backColor As System.Drawing.Brush = New System.Drawing.SolidBrush(Color.White)
' loop through the child elements
For Each uieChild In drawParams.Element.ChildElements
Dim LeftPading As Integer = ChildPadding
' test for a RowUIElement
If uieChild.GetType() Is GetType(Infragistics.Win.UltraWinGrid.RowUIElement) Then
uieRow = uieChild
Dim TextFormat As New StringFormat
TextFormat.LineAlignment = StringAlignment.Center
Dim CellRectangle As RectangleF
Dim ActualWidth As Integer
If uieRow.Rect.Width() >= Me.DropDownWidth Then
ActualWidth = uieRow.Rect.Width
Else
ActualWidth = Me.DropDownWidth
Me.DisplayLayout.Bands(0).Columns(3).Width += Me.DropDownWidth — uieRow.Rect.Width
End If
Dim RowRect As New System.Drawing.Rectangle(uieRow.Rect.Left, uieRow.Rect.Top, ActualWidth, uieRow.Rect.Height)
If uieRow.Row.Selected Then
'draw background
drawParams.Graphics.FillRectangle(System.Drawing.Brushes.Black, RowRect)
Dim ColumnPadding = 0
' draw each visible cell in row
For Each Cell As Infragistics.Win.UltraWinGrid.UltraGridCell In uieRow.Row.Cells
If Not Cell.Column.Hidden Then
If Cell.Column.Index = ColumnToDisplay And Cell.Text.IndexOf(":") > 0 Then
CellRectangle = New RectangleF(uieRow.Rect.Left + LeftPading + ColumnPadding, uieRow.Rect.Top, Cell.Column.Width — 2, textFont.Height)
Dim ChildText = Cell.Text.Substring(Cell.Text.IndexOf(":") + 1)
drawParams.Graphics.DrawString(ChildText, textFont, System.Drawing.Brushes.White, CellRectangle)
Else
CellRectangle = New RectangleF(uieRow.Rect.Left + ColumnPadding, uieRow.Rect.Top, Cell.Column.Width — 2, textFont.Height)
drawParams.Graphics.DrawString(Cell.Text, textFont, System.Drawing.Brushes.White, CellRectangle)
End If
ColumnPadding += Cell.Column.Width
End If
Next
Else
'draw background
drawParams.Graphics.FillRectangle(backColor, RowRect)
Dim ColumnPadding = 0
' draw each visible cell in row
For Each Cell As Infragistics.Win.UltraWinGrid.UltraGridCell In uieRow.Row.Cells
If Not Cell.Column.Hidden Then
If Cell.Column.Index = ColumnToDisplay And Cell.Text.IndexOf(":") > 0 Then
CellRectangle = New RectangleF(uieRow.Rect.Left + LeftPading + ColumnPadding, uieRow.Rect.Top, Cell.Column.Width — 2, textFont.Height)
Dim ChildText = Cell.Text.Substring(Cell.Text.IndexOf(":") + 1)
drawParams.Graphics.DrawString(ChildText, textFont, foreColor, CellRectangle)
Else
CellRectangle = New RectangleF(uieRow.Rect.Left + ColumnPadding, uieRow.Rect.Top, Cell.Column.Width — 2, textFont.Height)
drawParams.Graphics.DrawString(Cell.Text, textFont, foreColor, CellRectangle)
End If
ColumnPadding += Cell.Column.Width
End If
Next
End If
End If
Next
Return True
End Function
'''<summary>IUIElementDrawFilter.GetPhasesToFilter — The code in the GetPhasesToFilter
''' method selects the elements on which custom drawing is to be performed by
''' returning DrawPhase.None</summary>
'''<param name="drawParams">Contains element to draw</param>
'''<returns>Returns Infragistics.Win.DrawPhase on which custom drawing is to be performed
'''</returns>
Private Function GetPhasesToFilter(ByRef drawParams As Infragistics.Win.UIElementDrawParams) As Infragistics.Win.DrawPhase Implements Infragistics.Win.IUIElementDrawFilter.GetPhasesToFilter
If Not drawParams.Element.GetType() Is GetType(Infragistics.Win.UltraWinGrid.RowColRegionIntersectionUIElement) Then
GetPhasesToFilter = Infragistics.Win.DrawPhase.None
Else
GetPhasesToFilter = Infragistics.Win.DrawPhase.BeforeDrawElement
End If
End Function
Re[2]: Infragistics UltraGrid - вместо combobox - treeview