Hello I have created this simple bit of code that displays a hierarchial orders grid (see screen1.jpg)
Now I want to hide the +/- buttons if there are no rows (ie Order Ref 2 & 4) - Having searched the threads and copied the functions from those threads (RadGridView1_ViewCellFormatting,IsExpandable & RadGridView1_ChildViewExpanding)
It just hides them all because rowInfo.ChildRows.Count =0! (as per screen2.jpg)
Can anybody spot where I'm going wrong?
Many thanks
Terry
Public
Class
Form1
Private
Sub
Form1_Load(sender
As
Object
, e
As
System.EventArgs)
Handles
Me
.Load
Dim
myOrders =
New
BindingList(Of Order)()
Dim
myOrderLines =
New
BindingList(Of OrderLines)()
myOrders.Add(
New
Order(1,
"01/01/2011"
,
"Order for Warehouse"
))
myOrders.Add(
New
Order(2,
"03/05/2011"
,
"Order for home"
))
myOrders.Add(
New
Order(3,
"12/05/2011"
,
"Order ref xyz"
))
myOrders.Add(
New
Order(4,
"16/05/2011"
,
"Order ref abc"
))
myOrderLines.Add(
New
OrderLines(1,
"Power Supply"
))
myOrderLines.Add(
New
OrderLines(1,
"Hard Disk"
))
myOrderLines.Add(
New
OrderLines(3,
"Keyboard"
))
myOrderLines.Add(
New
OrderLines(3,
"Mouse"
))
RadGridView1.AutoGenerateHierarchy =
False
RadGridView1.AutoGenerateColumns =
True
Dim
OrderLinesTemplate
As
New
GridViewTemplate
OrderLinesTemplate.AllowAddNewRow =
False
OrderLinesTemplate.DataSource = myOrderLines
'RadGridView1.MasterTemplate.Templates.Add(RolesAndPositionTemplate)
Me
.RadGridView1.MasterTemplate.Templates.Add(OrderLinesTemplate)
'create the relation
Dim
relation
As
New
GridViewRelation(RadGridView1.MasterTemplate)
relation.RelationName =
"Order Lines"
relation.ParentColumnNames.Add(
"OrderId"
)
relation.ChildColumnNames.Add(
"OrderLineId"
)
relation.ChildTemplate = OrderLinesTemplate
Me
.RadGridView1.Relations.Add(relation)
Me
.RadGridView1.DataSource = myOrders
End
Sub
Private
Sub
RadGridView1_ViewCellFormatting(sender
As
Object
, e
As
Telerik.WinControls.UI.CellFormattingEventArgs)
Handles
RadGridView1.ViewCellFormatting
Dim
cellX
As
GridGroupExpanderCellElement = TryCast(e.CellElement, GridGroupExpanderCellElement)
If
cellX IsNot
Nothing
AndAlso
TypeOf
e.CellElement.RowElement
Is
GridDataRowElement
Then
If
Not
IsExpandable(cellX.RowInfo)
Then
cellX.Expander.Visibility = ElementVisibility.Hidden
Else
cellX.Expander.Visibility = ElementVisibility.Visible
End
If
End
If
End
Sub
Private
Function
IsExpandable(rowInfo
As
GridViewRowInfo)
As
Boolean
If
rowInfo.ChildRows IsNot
Nothing
AndAlso
rowInfo.ChildRows.Count > 0
Then
Return
True
Else
Return
False
End
If
End
Function
Private
Sub
RadGridView1_ChildViewExpanding(sender
As
Object
, e
As
Telerik.WinControls.UI.ChildViewExpandingEventArgs)
Handles
RadGridView1.ChildViewExpanding
e.Cancel =
Not
IsExpandable(e.ParentRow)
End
Sub
private
void
radDock1_DockWindowClosing(
object
sender, DockWindowCancelEventArgs e)
{
if
(RadMessageBox.Show(
"Are you sure"
,
"Confirm"
, MessageBoxButtons.YesNo, RadMessageIcon.Question, MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.No) {
e.Cancel =
true
;
}
}
After some extensive tests we noticed that Telerik's WinForm controls do not behave well in an Access environment. In a .Net application the controls work just fine.
Here's some examples of things we've seen:
I know the controls are not exactly intended to be used like this, but is there anyone else who had similar experiences with the WinForms controls? And has a solution to make the controls more stable?
Hi
How to sort pages in RadPageView?
I was looking for method Sort or Comparer property but I did not find anything. Is it possible to sort pages in RadPageView?
I use version 2011.1.11.419.
Regards