Telerik Forums
UI for WPF Forum
12 answers
1.2K+ views
hi,

1. i have a dock control in a grid, the Height of the the row is set to "auto" and i get an exception:
"Placing Docking control in a panel or control that measures it with infinite width or height is not supported in the current version. You can disable this error by setting the AllowUnsafeMode property of the RadDocking control."

if the Height is set to a number or to " * " it's works fine.
is this behavior normal?

2. one other thing (a small one):
when a pane is set to auto-hide, i place the mouse pointer on it and it shows, 
then when i place the pointer on the top of the pane, 
between the header text and the buttons the pane hides again, a little annoying, i've checked it on another 
computer and this happens again.

thanks in advance,

Lior.


Georgi
Telerik team
 answered on 24 Feb 2017
8 answers
199 views
Hi,

I downloaded the demo code and ran it with Visual Studio 2012 on Windows 7.
When I click on Explore All Controls and then on Radial Menu, this Exception is thrown:

FileNotFoundException
Could not load file or assembly 'Telerik.Windows.Themes.Windows8, Culture=neutral' or one of its dependencies. The system cannot find the file specified.

at this location in the code:
> QuickStart.Common.dll!Telerik.Windows.Controls.QuickStart.Common.Helpers.ApplicationThemeManager.EnsureFrameworkElementResourcesForTheme(System.Windows.FrameworkElement element, string themeName) Line 257 + 0x31 bytes C#

Sebastien
Kalin
Telerik team
 answered on 23 Feb 2017
1 answer
153 views

Hi

 

I've added a button to my RadGridView via the below:

 

Dim col As New MyDeleteButtonColumn()
RadGridView1.Columns.Add(col)

Public Class MyDeleteButtonColumn
Inherits Telerik.Windows.Controls.GridViewColumn
Public Overrides Function CreateCellElement(cell As GridViewCell, dataItem As Object) As FrameworkElement
Dim btn As New RadButton()
btn.Content = "MD"
btn.[AddHandler](Button.ClickEvent, New RoutedEventHandler(AddressOf btn_Click))
Return btn
End Function
Private Sub btn_Click(sender As Object, e As RoutedEventArgs)
     Dim win2 As New form2("gvcell0value:)")
win2.Show()
End Sub

 

Within the but_Click I need to get the value of from cell 0 to pass throught to a new form opening

How could I achive this?

Many thanks

Stefan Nenchev
Telerik team
 answered on 23 Feb 2017
3 answers
290 views

Lets assume that the view is the following:

<Window x:Class="RadGridViewSelectionBug.MainWindow"
        xmlns:local="clr-namespace:RadGridViewSelectionBug"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525" WindowState="Maximized">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition />
        </Grid.RowDefinitions>
 
        <Button HorizontalAlignment="Left" Click="Button_Click">Click Me</Button>
        <telerik:RadGridView x:Name="radGridView"
                             Grid.Row="1"
                             NewRowPosition="None" 
                             RowIndicatorVisibility="Collapsed"
                             ItemsSource="{Binding DataView}"
                             ShowGroupPanel="False"
                             AutoGenerateColumns="True"
                             IsReadOnly="True"
                             IsFilteringAllowed="False"
                             EnableColumnVirtualization="True"
                             CanUserSortColumns="False"
                             CanUserDeleteRows="False"
                             CanUserInsertRows="False"
                             SelectionMode="Extended"
                             SelectionUnit="Cell"
                             MinColumnWidth="50"
                             CanUserReorderColumns="False"
                             CanUserFreezeColumns="False"
                             GroupRenderMode="Flat"
                             ValidatesOnDataErrors="None"
                             ColumnWidth="75"
                             FrozenColumnCount="1"
                             FrozenColumnsSplitterVisibility="Collapsed"
                             ClipboardCopyMode="Cells"
                             ClipboardPasteMode="Cells"
                             TextBlock.TextAlignment="Center">
        </telerik:RadGridView>
    </Grid>
</Window>

 

The Code behind is the following:

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
        this.DataContext = new MainViewModel();
        radGridView.SelectedCellsChanged += RadGridView_SelectedCellsChanged;
    }
 
    private void RadGridView_SelectedCellsChanged(object sender, Telerik.Windows.Controls.GridView.GridViewSelectedCellsChangedEventArgs e)
    {
        var selectedCells = (sender as RadGridView).SelectedCells.Where(c => c != null).ToList();
 
        if (selectedCells.Any())
        {
            var firstCell = selectedCells.First();
            var lastCell = selectedCells.Last();
 
            int fromRowIndex = firstCell.Column.DataControl.Items.IndexOf(firstCell.Item);
            int fromColIndex = firstCell.Column.DisplayIndex;
 
            int toRowIndex = lastCell.Column.DataControl.Items.IndexOf(lastCell.Item);
            int toColIndex = lastCell.Column.DisplayIndex;
 
            Console.WriteLine(string.Format("{0}, {1}, {2}, {3}", fromRowIndex, fromColIndex, toRowIndex, toColIndex));
        }
    }
 
    private void Button_Click(object sender, RoutedEventArgs e)
    {
        (this.DataContext as MainViewModel).RebuildData();
    }
}

 

And the MainViewModel code is:

public class MainViewModel : ViewModelBase
{
    private DataTable _dataTable;
 
    public MainViewModel()
    {
        _dataTable = new DataTable();
        _dataTable.Columns.Add(new DataColumn()
        {
            Caption = "Col1",
            DataType = typeof(int),
        });
        _dataTable.Columns.Add(new DataColumn()
        {
            Caption = "Col2",
            DataType = typeof(int),
        });
        _dataTable.Columns.Add(new DataColumn()
        {
            Caption = "Col3",
            DataType = typeof(int),
        });
 
        for (int i = 0; i <100; i++)
        {
            var row = _dataTable.NewRow();
            for (int j = 0; j < 3; j++)
            {
                row[j] = 0;
            }
            _dataTable.Rows.Add(row);
        }
    }
 
    internal void RebuildData()
    {
        var dataTable = new DataTable();
        dataTable.Columns.Add(new DataColumn()
        {
            Caption = "Col1",
            DataType = typeof(int),
        });
        dataTable.Columns.Add(new DataColumn()
        {
            Caption = "Col2",
            DataType = typeof(int),
        });
        dataTable.Columns.Add(new DataColumn()
        {
            Caption = "Col3",
            DataType = typeof(int),
        });
 
        for (int i = 0; i < 10; i++)
        {
            var row = dataTable.NewRow();
            for (int j = 0; j < 3; j++)
            {
                row[j] = 0;
            }
            dataTable.Rows.Add(row);
        }
 
        DataTable = dataTable;
    }
 
    public DataView DataView
    {
        get
        {
            return _dataTable.DefaultView;
        }
    }
 
    public DataTable DataTable
    {
        get
        {
            return _dataTable;
        }
        set
        {
            _dataTable = value;
            OnPropertyChanged("DataView");
        }
    }
 
}

 

Run the code. Then Press Ctrl + A, in order to select all cells.

Then click on the Button.

 

You should get an exception (The grid view code tries to access a column with index that does not exist).

If I remove the cellInfo null check, and just write:

var selectedCells = (sender as RadGridView).SelectedCells;

Then I'll get that few cells in the SelectedCells are nulls (I might get that the firstCell, or the lastCell are nulls).

 

 

Now for another interesting bug:

Restart the code.

Select the first cell (upper left corner). The code shows Row = 0 and Col = 0 --> Good.

Now Click the button.. The selection is cleared...

Now Select the first cell again. The code shows Row = -1, Col = 0. (WTF?)

Now, any cell that you will select on the first row will give you that result. But if you select a cell from a different row, and then reselect a cell from the first row, then the problem is fixed.

 

 

Btw, getting the Item from the Added cells and checking its row index does give the correct result, but what I'm trying to do is to have the user have only 1 selected region (A rectangle of selected cells), so I can have a from row, from cell, to row, and to cell information.

 

So, in my code, I also clear selection in Grid PreviewMouseLeftButtonDown.

Any other suggestions of having only rectangular selection will be welcome (since right now, clicking on blank area, or clicking the scrollbar also clears the selection).

 

Furthermore, any suggestions on how to get the correct selected region will be welcome.

 

Thanks

BENN
Top achievements
Rank 1
 answered on 23 Feb 2017
1 answer
61 views

My project need insert chart to spreadsheet,and print all content.

I know devexpress control can add chart to spreadsheet.

when the spreadsheet can support the chart

Dinko | Tech Support Engineer
Telerik team
 answered on 23 Feb 2017
2 answers
108 views

Hi to all,

I have a simple grid, that I'm using with MVVM pattern.

<Style x:Key="ListEditableFlatStyle" TargetType="telerik:RadGridView" BasedOn="{StaticResource RadGridViewStyle}">
    <Setter Property="CanUserDeleteRows" Value="True"/>
    <Setter Property="CanUserFreezeColumns" Value="True"/>
    <Setter Property="CanUserInsertRows" Value="True"/>
    <Setter Property="CanUserReorderColumns" Value="False"/>
    <Setter Property="CanUserResizeColumns" Value="True"/>
    <Setter Property="CanUserResizeRows" Value="False"/>
    <Setter Property="CanUserSelect" Value="True"/>
    <Setter Property="CanUserSortColumns" Value="False"/>
    <Setter Property="CanUserSortGroups" Value="False"/>
    <Setter Property="ShowGroupPanel" Value="False"/>
    <Setter Property="ShowSearchPanel" Value="False"/>
    <Setter Property="AutoGenerateColumns" Value="False"/>
    <Setter Property="IsReadOnly" Value="False"/>
    <Setter Property="SelectionMode" Value="Extended"/>
    <Setter Property="SelectionUnit" Value="FullRow"/>
    <Setter Property="IsLocalizationLanguageRespected" Value="False"/>
    <Setter Property="Margin" Value="2"/>
    <Setter Property="NewRowPosition" Value="Bottom"/>
    <Setter Property="GroupRenderMode" Value="Flat"/>
</Style>
 
<telerik:RadGridView ItemsSource="{Binding MisureModelli}" Style="{StaticResource ListEditableFlatStyle}"
                     GroupRenderMode="Flat"
                     Grid.Row="6" Grid.ColumnSpan="4">
    <telerik:RadGridView.Columns>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding PesoLordo, StringFormat=\{0:N2\}}" Header="Peso Lordo (Kg)" HeaderTextAlignment="Right"
                        TextAlignment="Right"/>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding PesoNetto, StringFormat=\{0:N2\}}" Header="Peso Netto (Kg)" HeaderTextAlignment="Right"
                        TextAlignment="Right"/>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding Volume, StringFormat=\{0:N3\}}" Header="Volume (m³)" HeaderTextAlignment="Right"
                        TextAlignment="Right" IsReadOnly="True"/>
    </telerik:RadGridView.Columns>
</telerik:RadGridView>

 

When I click "new row", it disappears exists row, I don't undestrand why.

Dario Concilio
Top achievements
Rank 2
 answered on 23 Feb 2017
1 answer
411 views

Dear Forum Members ,

 

I have a requirement to copy paste the Excel content to Radgrid view , Here few of the columns of the grid are Read only , i tried out the Below options , Any suggestions appreciated .

In Rad gridview is set the below properties

ClipboardCopyMode="Cells" ClipboardPasteMode="AllSelectedCells,Cells" SelectionMode="Extended" SelectionUnit="Cell"

 

and in the behaviour have the PastingCellClipboardContent event to check on the data and map it accordingly , issue here is that for read-only columns this is not fired , please do suggest

 

regards
Anand

 

Stefan Nenchev
Telerik team
 answered on 23 Feb 2017
1 answer
82 views

Hi, I inputted a table onto my document with 1 row and 2 columns.

I then inputted a Custom Merge Field in column 2. My Custom Merge field inputs a table. Code is below

protected override DocumentFragment GetResultFragment()
{
    UniversalDTO universalDTO = this.Document.MailMergeDataSource.CurrentItem as UniversalDTO;
    if (universalDTO == null)
    {
        return null;
    }
 
    if (this.PropertyPath == "Collaterals")
    {
        Table table = new Table();
 
 
        foreach (var coillateral in universalDTO.Collaterals)
        {
            Span span = new Span(coillateral.Type.Value);
            span.FontSize = 11.5;
            Paragraph paragraph = new Paragraph();
            paragraph.Inlines.Add(span);
 
            Span span2 = new Span(coillateral.Description);
            span2.FontSize = 11.5;
            Paragraph paragraph2 = new Paragraph();
            paragraph2.Inlines.Add(span2);
 
            TableCell cell = new TableCell();
            cell.Blocks.Add(paragraph);
            cell.Borders = new TableCellBorders(new Border(1, BorderStyle.Single, Colors.Transparent));
 
            TableCell cell2 = new TableCell();
            cell2.Blocks.Add(paragraph2);
            cell2.Borders = new TableCellBorders(new Border(1, BorderStyle.Single, Colors.Transparent));
 
            TableRow row = new TableRow();
            row.Cells.Add(cell);
            row.Cells.Add(cell2);
            table.AddRow(row);
        }
 
        Section section = new Section();
        section.Blocks.Add(table);
 
        RadDocument document = new RadDocument();
        document.Sections.Add(section);
 
        document.MeasureAndArrangeInDefaultSize();
        return new DocumentFragment(document);
    }
 
    return null;
}

 

The issue I'm having is depicted by the image below, there's a space ontop of the nested table. If tried to delete in the document, it deletes the table. That empty line can be deleted in word though.

http://imgur.com/cf22ee44-9cdd-4840-b045-a9500c8d0569

 

Code View 

 

http://imgur.com/LQirves

band
Top achievements
Rank 1
 answered on 22 Feb 2017
4 answers
806 views

I have a few columns in my RadGridView, which I would like to filter - but not to allow Search as You Type.

Is there  any way to do this?

 

In addition: I have boolean values, which I show as "Yes" and "No" in the grid - but in the filters, they are shown as "True" and "False". It there any way to change this to let the filter sow "Yes" and "No", too?

Best regards

Inger Marie

Inger Marie
Top achievements
Rank 1
 answered on 22 Feb 2017
9 answers
867 views

Hi,
I have a specific behavior I want to achieve with respect to the AutoCompleteBox.

Requirements:

  1. When the box is empty the pop-up must suggest all options, much like a combo-box does
  2. When the box gets focus, the pop-up must open and show the corresponding suggestions
  3. Selection must be achieved through hitting enter key or clicking an item on the pop-up

Tried solution:

  • Implement a FilteringBehavior to return all items when search text is empty

public class MyFilteringBehavior : FilteringBehavior
{
    public override IEnumerable<object> FindMatchingItems(string searchText, IList items, IEnumerable<object> escapedItems, string textSearchPath,
        TextSearchMode textSearchMode)
    {
        if (string.IsNullOrEmpty(searchText))
            return items.Cast<object>();
        return base.FindMatchingItems(searchText, items, escapedItems, textSearchPath, textSearchMode);
    }
}

  •  Upon receiving a GotFocus event perform a Populate on the auto-complete box

private void Classes_GotFocus(object sender, RoutedEventArgs e)
{
    var box = (RadAutoCompleteBox) sender;
    box.Populate(box.SearchText);
    //box.IsDropDownOpen = true; // Not necessary
}

  • Setting up the RadAutoCompleteBox on Xaml

<telerik:RadAutoCompleteBox Grid.Row="4" Grid.Column="2"
         Name="Classes"
         ItemsSource="{Binding Classes}"
         AutoCompleteMode="SuggestAppend"
         SelectionMode="Multiple"
         TextSearchMode="Contains"
         IsHighlighted="True"
         FilteringBehavior="{StaticResource MyFilteringBehavior}"
         GotFocus="Classes_GotFocus"/>

Expected behavior:

  • Requirements 1 and 2 are achieved successfully
  • With a highlighted item in the popup, hitting enter commits the selection into the box and closes the popup

Unexpected/unwanted effects:

  • While cycling focus through a series of text boxes and auto complete boxes the first option gets selected when the tab key is hit
  • Users cannot select any item while mouse-left-clicking on items in the pop-up

Is there any way to avoid the unwanted behavior while on this setup?

Nasko
Telerik team
 answered on 22 Feb 2017
Narrow your results
Selected tags
Tags
GridView
General Discussions
Chart
RichTextBox
Docking
ScheduleView
ChartView
TreeView
Diagram
Map
ComboBox
TreeListView
Window
RibbonView and RibbonWindow
PropertyGrid
DragAndDrop
TabControl
TileView
Carousel
DataForm
PDFViewer
MaskedInput (Numeric, DateTime, Text, Currency)
AutoCompleteBox
DatePicker
Buttons
ListBox
GanttView
PivotGrid
Spreadsheet
Gauges
NumericUpDown
PanelBar
DateTimePicker
DataFilter
Menu
ContextMenu
TimeLine
Calendar
Installer and Visual Studio Extensions
ImageEditor
BusyIndicator
Slider
Expander
TileList
PersistenceFramework
DataPager
Styling
TimeBar
OutlookBar
TransitionControl
Book
FileDialogs
ToolBar
ColorPicker
TimePicker
SyntaxEditor
MultiColumnComboBox
VirtualGrid
Wizard
ExpressionEditor
NavigationView (Hamburger Menu)
DesktopAlert
WatermarkTextBox
BarCode
SpellChecker
DataServiceDataSource
EntityFrameworkDataSource
RadialMenu
ChartView3D
Data Virtualization
BreadCrumb
ProgressBar
Sparkline
LayoutControl
TabbedWindow
ToolTip
CloudUpload
ColorEditor
TreeMap and PivotMap
EntityFrameworkCoreDataSource (.Net Core)
HeatMap
Chat (Conversational UI)
VirtualizingWrapPanel
Calculator
NotifyIcon
TaskBoard
TimeSpanPicker
BulletGraph
WebCam
CardView
DataBar
Licensing
FilePathPicker
PasswordBox
Rating
SplashScreen
Accessibility
Callout
CollectionNavigator
Localization
AutoSuggestBox
HighlightTextBlock
Security
TouchManager
StepProgressBar
VirtualKeyboard
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
+? more
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?