Hi,
I have a custom cell layout, similar to a Business Card, and it lays out exactly correctly. However I want to instruct the grid to obey a minimum size for the cell, but I cannot seem to get it right.
Heres my code from the custom GridDataCellElement - I wonder if you can spot the problem or sugges a better way of forcing a minumum cell size ?
Thanks.
I have a custom cell layout, similar to a Business Card, and it lays out exactly correctly. However I want to instruct the grid to obey a minimum size for the cell, but I cannot seem to get it right.
Heres my code from the custom GridDataCellElement - I wonder if you can spot the problem or sugges a better way of forcing a minumum cell size ?
Thanks.
protected override void CreateChildElements() |
{ |
base.CreateChildElements(); |
this.pictureBox = new Telerik.WinControls.UI.RadButtonElement(); |
this.pictureBox.MinSize = new Size(150, 150); |
this.pictureBox.Size = this.pictureBox.MinSize; |
this.pictureBox.AutoSize = false; |
this.Children.Add(this.pictureBox); |
this.dataLabelsAndValues = new List<Telerik.WinControls.RadElement>(); |
foreach(string propertyName in column.ColumnDefinition.SelectedFields) |
{ |
iSIMS.DataModel.SimpleProperty fieldDefinition = iSIMS.DataEntity.DataEntity.DataModel.GetField<iSIMS.DataModel.SimpleProperty>(propertyName); |
if (fieldDefinition != null) |
{ |
Telerik.WinControls.UI.RadLabelElement label = new Telerik.WinControls.UI.RadLabelElement(); |
label.Text = fieldDefinition.Description; |
label.Font = new Font(label.Font, FontStyle.Bold); |
label.MinSize = new Size(100, 20); |
label.Size = label.MinSize; |
label.AutoSize = false; |
dataLabelsAndValues.Add(label); |
Telerik.WinControls.UI.RadLabelElement textBox = new Telerik.WinControls.UI.RadLabelElement(); |
textBox.Tag = propertyName; |
textBox.AutoSize = false; |
textBox.MinSize = new Size(100, 20); |
textBox.Size = textBox.MinSize; |
dataLabelsAndValues.Add(textBox); |
} |
} |
this.Children.AddRange(dataLabelsAndValues.ToArray()); |
} |
protected override SizeF ArrangeOverride(SizeF finalSize) |
{ |
SizeF size = base.ArrangeOverride(finalSize); |
RectangleF clientRect = GetClientRectangle(finalSize); |
int controlOffset = 0; |
int maxWidth = 0; |
int maxHeight = 0; |
foreach (Telerik.WinControls.RadElement element in this.Children) |
{ |
if (element == pictureBox) |
{ |
element.Arrange( |
new RectangleF( |
clientRect.Left+5, |
clientRect.Top+5, |
150, |
150) |
); |
} |
else |
{ |
element.Arrange( |
new RectangleF( |
clientRect.Left + 150 + 5 +5, |
clientRect.Top + (controlOffset * 20) +5, |
clientRect.Width - (150 + 5), |
20) |
); |
controlOffset++; |
} |
} |
return size; |
} |