var
agencyValues = (Agency)agencyBindingSource.Current;
if (agencyValues != null && !agencyValues.Zip.IsNotNullOrEmpty())
{
zipCodeMasked.Value =
null;
}
I have been noticing that on your RadForm there is a problem with how you get your GetDCEx. To keep it short I'll give you a short piece of code that can help you.
if
(msg.Msg != (int)WindowMessages.WM_NCPAINT)
{
return GetWindowDC(msg.HWnd);
}
int flags = (int)(DCX.DCX_CACHE | DCX.DCX_CLIPSIBLINGS
|
DCX.DCX_WINDOW );
IntPtr zero = IntPtr.Zero;
if (msg.WParam.ToInt32() != 1)
{
flags |= (
int)DCX.DCX_INTERSECTRGN;
zero = msg.WParam;
}
return GetDCEx(msg.HWnd, zero, flags);
| Private Function newButton() As RadButtonElement |
| Dim radB As New RadButtonElement() |
| radB.MaxSize = New Size(12, 12) |
| AddHandler radB.Click, AddressOf HideTab |
| radB.Font = New System.Drawing.Font("Verdana", 6, FontStyle.Regular, GraphicsUnit.Point, (DirectCast(0, Byte))) |
| radB.Text = "x" |
| radB.TextAlignment = ContentAlignment.MiddleRight |
| 'Alignment defines where the button will be placed on the tab |
| radB.Alignment = ContentAlignment.TopRight |
| Return radB |
| End Function |
| Private Sub HideTab(ByVal sender As Object, ByVal e As EventArgs) |
| Dim buttonElement As RadElement = (DirectCast(sender, RadElement)) |
| buttonElement.Parent.Visibility = ElementVisibility.Collapsed |
| End Sub |
| using System; |
| using System.Collections; |
| using System.IO; |
| using System.Web.UI; |
| using System.Web.UI.WebControls; |
| using Telerik.Web.UI; |
| namespace WebApplication1 |
| { |
| public class GridSettingsPersister |
| { |
| private RadGrid gridInstance; |
| public GridSettingsPersister( RadGrid gridInstance ) |
| { |
| this.gridInstance = gridInstance; |
| } |
| //this method should be called on Render |
| public string SaveSettings() |
| { |
| object[] gridSettings = new object[4]; |
| //Save groupBy |
| GridGroupByExpressionCollection groupByExpressions = gridInstance.MasterTableView.GroupByExpressions; |
| object[] groupExpressions = new object[groupByExpressions.Count]; |
| int count = 0; |
| foreach( GridGroupByExpression expression in groupByExpressions ) |
| { |
| groupExpressions[count] = ((IStateManager)expression).SaveViewState(); |
| count++; |
| } |
| gridSettings[0] = groupExpressions; |
| //Save sort expressions |
| gridSettings[1] = ((IStateManager)gridInstance.MasterTableView.SortExpressions).SaveViewState(); |
| //Save columns order |
| int columnsLength = gridInstance.MasterTableView.Columns.Count + |
| gridInstance.MasterTableView.AutoGeneratedColumns.Length; |
| Pair [] columnOrder = new Pair[ columnsLength ]; |
| ArrayList allColumns = new ArrayList( columnsLength ); |
| allColumns.AddRange(gridInstance.MasterTableView.Columns ); |
| allColumns.AddRange(gridInstance.MasterTableView.AutoGeneratedColumns); |
| int i = 0; |
| foreach( GridColumn column in allColumns ) |
| { |
| Pair p = new Pair(); |
| p.First = column.OrderIndex; |
| p.Second = column.HeaderStyle.Width; |
| columnOrder[i] = p; |
| i++; |
| } |
| gridSettings[2] = columnOrder; |
| //Save filter expression |
| gridSettings[3] = (object)gridInstance.MasterTableView.FilterExpression; |
| LosFormatter formatter = new LosFormatter(); |
| StringWriter writer = new StringWriter(); |
| formatter.Serialize( writer, gridSettings ); |
| return writer.ToString(); |
| } |
| //this method should be called on PageInit |
| public void LoadSettings( string settings ) |
| { |
| LosFormatter formatter = new LosFormatter(); |
| StringReader reader = new StringReader( settings ); |
| object[] gridSettings = (object[])formatter.Deserialize( reader ); |
| //Load groupBy |
| GridGroupByExpressionCollection groupByExpressions = this.gridInstance.MasterTableView.GroupByExpressions; |
| groupByExpressions.Clear(); |
| object[] groupExpressionsState = (object[])gridSettings[0]; |
| int count = 0; |
| foreach( object obj in groupExpressionsState ) |
| { |
| GridGroupByExpression expression = new GridGroupByExpression(); |
| ((IStateManager)expression).LoadViewState( obj ); |
| groupByExpressions.Add( expression ); |
| count++; |
| } |
| //Load sort expressions |
| this.gridInstance.MasterTableView.SortExpressions.Clear(); |
| ((IStateManager)this.gridInstance.MasterTableView.SortExpressions).LoadViewState( gridSettings[1] ); |
| //Load columns order |
| int columnsLength = this.gridInstance.MasterTableView.Columns.Count + |
| this.gridInstance.MasterTableView.AutoGeneratedColumns.Length; |
| Pair [] columnOrder = (Pair[])gridSettings[2]; |
| if ( columnsLength == columnOrder.Length) |
| { |
| ArrayList allColumns = new ArrayList( columnsLength ); |
| allColumns.AddRange(this.gridInstance.MasterTableView.Columns ); |
| allColumns.AddRange(this.gridInstance.MasterTableView.AutoGeneratedColumns); |
| int i = 0; |
| foreach( GridColumn column in allColumns ) |
| { |
| column.OrderIndex = (int)columnOrder[i].First; |
| column.HeaderStyle.Width = (Unit)columnOrder[i].Second; |
| i++; |
| } |
| } |
| //Load filter expression |
| this.gridInstance.MasterTableView.FilterExpression = (string)gridSettings[3]; |
| } |
| } |
Hi,
Is it possible to custom the context menu on grid header?
In particular, I want to add a menu item for grouping my grid on one of the columns. That is the only one column my users are likely to group the grid, so I don't want to show the whole group panel.
I may want to add some anther menu items too.
Thanks.