Posted 27 November 2019, 4:18 am EST
Hello Andrew,
the content menu after clicking the right click on the sheet tool bar
Please use the following lines of code:
c1FlexSheet1.EditOptions = C1.WPF.FlexGrid.FlexSheetEditOptions.None;
i want to hide the “add sheet” button at the bottom
Please use the following line of code:
private void C1FlexSheet1_Loaded(object sender, RoutedEventArgs e)
{
foreach (NewSheet item in FindVisualChildren<NewSheet>(c1FlexSheet1))
{
item.Visibility = Visibility.Collapsed;
TextBlock tsl;
}
}
public static IEnumerable<T> FindVisualChildren<T>(DependencyObject depObj) where T : DependencyObject
{
if (depObj != null)
{
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)
{
DependencyObject child = VisualTreeHelper.GetChild(depObj, i);
if (child != null && child is T)
{
yield return (T)child;
}
foreach (T childOfChild in FindVisualChildren<T>(child))
{
yield return childOfChild;
}
}
}
}
i would like to disable users to rename the sheet name.
Please use the following lines of code:
private void C1FlexSheet1_Loaded(object sender, RoutedEventArgs e)
{
ContentPresenter itemTab = FindChild<ContentPresenter>(c1FlexSheet1, "TabPanelPresenter");
foreach (TextBlock item in FindVisualChildren<TextBlock>(itemTab))
{
item.IsEnabled = false;
}
}
public static T FindChild<T>(DependencyObject parent, string childName)
where T : DependencyObject
{
// Confirm parent and childName are valid.
if (parent == null) return null;
T foundChild = null;
int childrenCount = VisualTreeHelper.GetChildrenCount(parent);
for (int i = 0; i < childrenCount; i++)
{
var child = VisualTreeHelper.GetChild(parent, i);
// If the child is not of the request child type child
T childType = child as T;
if (childType == null)
{
// recursively drill down the tree
foundChild = FindChild<T>(child, childName);
// If the child is found, break so we do not overwrite the found child.
if (foundChild != null) break;
}
else if (!string.IsNullOrEmpty(childName))
{
var frameworkElement = child as FrameworkElement;
// If the child's name is set for search
if (frameworkElement != null && frameworkElement.Name == childName)
{
// if the child's name is of the request name
foundChild = (T)child;
break;
}
}
else
{
// child element found.
foundChild = (T)child;
break;
}
}
return foundChild;
}
Hope it helps.
Thanks,
Mohit