Demonstrates the column properties that affect the operations, which the user can perform with the column (e.g column protection).

| Language: C# |
using Nevron.Nov;
using Nevron.Nov.Data;
using Nevron.Nov.DataStructures;
using Nevron.Nov.Dom;
using Nevron.Nov.Editors;
using Nevron.Nov.Graphics;
using Nevron.Nov.Grid;
using Nevron.Nov.Layout;
using Nevron.Nov.Presentation;
using Nevron.Nov.UI;
using Nevron.Nov.Windows.Forms;
using System;
using System.Windows.Forms;
namespace NovWinFormsProject
{
public partial class Form1 : Form
{
#region Constructors
public Form1()
{
InitializeComponent();
// Set form title
Text = "NOV WinForms - NColumnProtectionExample";
// Create the NOV example and its controls
NWidget exampleContent = CreateExampleContent();
NWidget exampleControls = CreateExampleControls();
if (exampleControls != null)
{
exampleControls.PreferredWidth = 300;
}
// Place the example and its controls in a pair box
NPairBox pairBox = new NPairBox(exampleContent, exampleControls);
pairBox.FillMode = ENStackFillMode.First;
pairBox.FitMode = ENStackFitMode.First;
pairBox.Margins = new NMargins(NDesign.HorizontalSpacing, NDesign.VerticalSpacing);
// Host the example in the form
NNovWidgetHost host = new NNovWidgetHost(pairBox);
host.Dock = DockStyle.Fill;
Controls.Add(host);
}
#endregion
#region Example
public NWidget CreateExampleContent()
{
m_GridView = new NTableGridView();
m_GridView.Grid.DataSource = NDummyDataSource.CreateProductsDataSource();
m_GridView.Grid.AllowSortColumns = true;
return m_GridView;
}
public NWidget CreateExampleControls()
{
NStackPanel stack = new NStackPanel();
// create the columns combo box
{
stack.Add(new NLabel("Select Column:"));
m_ColumnsComboBox = new NComboBox();
stack.Add(m_ColumnsComboBox);
for (int i = 0; i < m_GridView.Grid.Columns.Count; i++)
{
NDataColumn column = m_GridView.Grid.Columns[i] as NDataColumn;
NComboBoxItem item = new NComboBoxItem(column.Title);
item.Tag = column;
m_ColumnsComboBox.Items.Add(item);
}
m_ColumnsComboBox.SelectedIndexChanged += OnColumnsComboBoxSelectedIndexChanged;
// create the columns
m_ColumnPropertiesHolder = new NContentHolder();
stack.Add(new NGroupBox("Selected Column Properties", m_ColumnPropertiesHolder));
}
return stack;
}
public string GetExampleDescription()
{
return @"
Demonstrates the column properties that affect the operations, which the user can perform with the column (e.g column protection).
";
}
///
/// Gets the relevant documentation links for the example
///
///
public (string Name, string Url)[] GetDocumentationUrls()
{
return new[]
{
("Grid Column Protection", "https://www.nevron.com/docs/openvision/grid-column-protection.html"),
("Grid Protection", "https://www.nevron.com/docs/openvision/grid-protection.html"),
};
}
#endregion
#region Implementation
#endregion
#region Event Handlers
void OnColumnsComboBoxSelectedIndexChanged(NValueChangeEventArgs arg)
{
NComboBoxItem item = m_ColumnsComboBox.SelectedItem;
if (item == null)
{
m_ColumnPropertiesHolder.Content = null;
return;
}
NDataColumn column = (NDataColumn)item.Tag;
NStackPanel columnPropertiesStack = new NStackPanel();
m_ColumnPropertiesHolder.Content = new NUniSizeBoxGroup(columnPropertiesStack);
NDesigner designer = NDesigner.GetDesigner(column);
NList editors = designer.CreateMemberEditors(column,
NDataColumn.AllowFilterProperty,
NDataColumn.AllowSortProperty,
NDataColumn.AllowGroupProperty,
NDataColumn.AllowFormatProperty,
NDataColumn.AllowEditProperty,
NDataColumn.AllowReorderProperty,
NDataColumn.AllowResizeProperty);
for (int i = 0; i < editors.Count; i++)
{
columnPropertiesStack.Add(editors[i]);
}
}
#endregion
#region Fields
NTableGridView m_GridView;
NComboBox m_ColumnsComboBox;
NContentHolder m_ColumnPropertiesHolder;
#endregion
#region Static Methods
#endregion
#region Constants
#endregion
#region Nested Types
#endregion
}
}