Telerik Forums
UI for WinForms Forum
1 answer
416 views
I know that there are many forum posts regarding filtering but I am having the hardest time trying to figure out how to accomplish this filter scenario:

I have 4 columns, Rdel, RAdd, RMod, RErr.
right now I have those columns set as Integer type in my datatable that I bind to the radgridview.  I handle changhing the values as need be but I need to be able to use filters so that I can not rows.  The way I have been trying to set the filters up I have used a custom context menu that uses a check type menuitem.  So when that value changes I am trying to add or remove descriptors.  So I may have many or no filters applied to the grid.  Right now I have something like this and it sort of works but I just wanted to kbnow if there is a better way of doing this.

  Public Const conMODIFIED As String = "RMod"
    Public Const conADDED As String = "RAdd"
    Public Const conDELETED As String = "RDel"
    Public Const conERRORROW As String = "RErr"
    Public Const conCHANGESLINK As String = "RCHGS"
    Public Const conROWID As String = "iRowID"
    Public Const conLSGRDTYPE As String = "lsGrdDataType"
    Public Const conCHFLAG As Integer = 1 '"x"
    Public Const conUCHFLAG As Integer = 0 '""

Public Sub ViewRowStates(Optional ByVal UnchangedRows As Boolean = True, Optional ByVal ChangedRows As Boolean = True, _
                         Optional ByVal AddedRows As Boolean = True, Optional ByVal DeletedRows As Boolean = True, _
                         Optional ByVal ErrorRows As Boolean = False)
 
    Me.FilterDescriptors.Remove(conADDED)
    Me.FilterDescriptors.Remove(conMODIFIED)
    Me.FilterDescriptors.Remove(conDELETED)
    Me.FilterDescriptors.Remove(conERRORROW)
    Dim cFilter As New Telerik.WinControls.Data.CompositeFilterDescriptor
    If Not UnchangedRows Then
        Dim compFilter As New Telerik.WinControls.Data.FilterDescriptor
        compFilter.PropertyName = conMODIFIED
        compFilter.Operator = Telerik.WinControls.Data.FilterOperator.IsEqualTo
        compFilter.Value = conCHFLAG
        compFilter.IsFilterEditor = True
        cFilter.FilterDescriptors.Add(compFilter)
    End If
    If Not ChangedRows Then
        Dim compFilter As New Telerik.WinControls.Data.FilterDescriptor
        compFilter.PropertyName = conMODIFIED
        compFilter.Operator = Telerik.WinControls.Data.FilterOperator.IsNotEqualTo
        compFilter.Value = conCHFLAG
        compFilter.IsFilterEditor = True
 
        cFilter.FilterDescriptors.Add(compFilter)
    End If
    If Not AddedRows Then
        Dim compFilter As New Telerik.WinControls.Data.FilterDescriptor
        compFilter.PropertyName = conADDED
        compFilter.Operator = Telerik.WinControls.Data.FilterOperator.IsNotEqualTo
        compFilter.Value = conCHFLAG
        compFilter.IsFilterEditor = True
 
        cFilter.FilterDescriptors.Add(compFilter)
    End If
    If Not DeletedRows Then
        Dim compFilter As New Telerik.WinControls.Data.FilterDescriptor
        compFilter.PropertyName = conDELETED
        compFilter.Operator = Telerik.WinControls.Data.FilterOperator.IsNotEqualTo
        compFilter.Value = conCHFLAG
        compFilter.IsFilterEditor = True
 
        cFilter.FilterDescriptors.Add(compFilter)
    End If
    If Not ErrorRows Then
        Dim compFilter As New Telerik.WinControls.Data.FilterDescriptor
        compFilter.PropertyName = conERRORROW
        compFilter.Operator = Telerik.WinControls.Data.FilterOperator.IsNotEqualTo
        compFilter.Value = conCHFLAG
        compFilter.IsFilterEditor = True
 
        cFilter.FilterDescriptors.Add(compFilter)
    End If
 
    Me.FilterDescriptors.Add(cFilter)
End Sub


If there is a better way to handle this scenario I would appreciate any suggestions.   The main thing is that I will add and remove filters on a single column and not want to lose the existing ones.  I would also need to be able to only see the rows that have a 1 in any of those columns.  A row could have a 1 in conAdded, conModified, and conDeleted.  That is so I can undo a single operation, such as a delete and still know that row was added.

Thanks once again.

Nick
Alexander
Telerik team
 answered on 28 Sep 2011
4 answers
431 views

Hello

I' going to Load Data from a nested generic list and Bind it to a radGridView. But I could not do that

this is my list:

List<List<string>> Mylist = new List<List<string>>();
and I add items into the list like below:

Mylist.Add(new List<string> { str1, str2, str3 });
at the end I set the gridview dataSource like this:

DGV1.DataSource = Mylist;
But it does not show the data from the list. the grid has 2 columns: Capacity, Count

Does anyone knows How I can Bind Mylist to the grid?

thanks

Julian Benkov
Telerik team
 answered on 28 Sep 2011
3 answers
227 views
Hi all,

I have a grid view with multiple columns, on which I want to apply filtering. When I use multiple filters, I get an exception of type

ArgumentOutOfRangeException
Index must be within the bounds of the List.
Parameter name: index

I can't find the cause of this, so does anybody have an idea of what's going wrong here? Grouping is also applied to the gridview (but I also tested without grouping with same exception as result).

The complete callstack is this:  
at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
   at System.Collections.Generic.List`1.Insert(Int32 index, T item)
   at System.Collections.ObjectModel.Collection`1.InsertItem(Int32 index, T item)
   at Telerik.Collections.Generic.NotifyCollection`1.InsertItem(Int32 index, T item)
   at Telerik.WinControls.UI.GridViewFilterDescriptorCollection.InsertItem(Int32 index, FilterDescriptor item)
   at System.Collections.ObjectModel.Collection`1.Add(T item)
   at Telerik.WinControls.UI.GridViewDataColumn.SetFilterDescriptor(FilterDescriptor value)
   at Telerik.WinControls.UI.RadListFilterMenuProvider.SetFilterDesriptor(GridViewDataColumn dataColumn, FilterDescriptor descriptor)
   at Telerik.WinControls.UI.RadListFilterMenuProvider.SetFilterDescriptor(FilterDescriptor descriptor)
   at Telerik.WinControls.UI.RadListFilterMenuProvider.ButtonOK_Click(Object sender, EventArgs e)
   at System.EventHandler.Invoke(Object sender, EventArgs e)
   at Telerik.WinControls.RadItem.OnClick(EventArgs e)
   at Telerik.WinControls.UI.RadButtonItem.OnClick(EventArgs e)
   at Telerik.WinControls.RadItem.DoClick(EventArgs e)
   at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
   at Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args)
   at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
   at Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args)
   at Telerik.WinControls.RadElement.DoMouseUp(MouseEventArgs e)
   at Telerik.WinControls.ComponentInputBehavior.OnMouseUp(MouseEventArgs e)
   at Telerik.WinControls.RadControl.OnMouseUp(MouseEventArgs e)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at Telerik.WinControls.RadControl.WndProc(Message& m)
   at Telerik.WinControls.UI.RadPopupControlBase.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.Run(Form mainForm)
   at WinWorkFlow.Program.Main(String[] args) in C:\Data\TeamProjects\devc#2009\MuseumWorkflow.root\MuseumWorkflow\WinWorkFlow\Program.cs:line 19

Thanks,
Christ
Julian Benkov
Telerik team
 answered on 28 Sep 2011
3 answers
124 views
Hi Team,

When doing some research on radmaskedittextbox(DateFormat)  i observed the following things.

1.By default maskedittextbox is allowing user to select only date between 1st of current month and
current date.

2.it is not allowing back date and also future date.

3.I am not able to clear the default date of radmaskedittextbox(DateFormat)  in runtime.

but in my application i want to allow back date and also future date.please tell me how to achieve this.

My Code snippet:
 private void rcStartDate_SelectionChanged(object sender, EventArgs e)
        {        
            rmebStartDate.Clear();
            rmebStartDate.Text = "";
            rmebEndDate.Value = "";
            
            rmebStartDate.Text = rcStartDate.SelectedDate.ToShortDateString().ToString();
            rcStartDate.Visible = false;
        }


Thanks
Ulaga
Peter
Telerik team
 answered on 28 Sep 2011
3 answers
639 views
Dear Telerik team,
                              I am designing a style for CheckBox control and the problem i face is "I cannot find property to change CheckMark color and backColor of the box for check mark. The property i guess would have worked is "RadCheckBoxElement.ToggleState=Ok.Pressed. But this property produces arrows etc ( for whatever shape i choose from available options)

none of the property changes the dark brown color of check and the box.

Thanks
Nikolay
Telerik team
 answered on 28 Sep 2011
2 answers
347 views
Hi all,
I've a problem with HTMLFormatProvider and font-style.
I'm using a radRichTextBox with richRibbonBar (but the problem is also present with a button that execute radRichTextBox1.toggleItalic() ). For example, I have write the string "foofoofoo" in italic inside radRichTextBox and then, using HTMLFormatProvider, I've got the text associated to the document. 

This is the ExportToHTML function

public string ExportToHTML(RadDocument document)
        {
            HtmlFormatProvider provider = new HtmlFormatProvider();
            return provider.Export(document);            
        }


This is the string returned:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Untitled</title><style type="text/css">
.p_4451D050 { margin: 0px 0px 12px 0px;text-align: left;text-indent: 0pt;padding: 0px 0px 0px 0px; } 
.s_C54C634B { font-family: 'Calibri';font-style: System.Collections.Specialized.StringCollection;font-size: 16px;color: #000000; } 
</style></head><body><p class="p_4451D050"><span class="s_C54C634B">foofoofoo</span></p></body></html>


There is a problem in font-style settings of css class, because it doesn't write "italic" but "System.Collections....".
So, when I send a html-email in this format I lost this font setting..

I've tried with XamlFormatProvider and italic (as fontweight) is correct.

Thanks a lot for your help
Keiichi-kun
Top achievements
Rank 1
 answered on 27 Sep 2011
2 answers
330 views
After searching the forums for some time (days, well 2 days) I finally have a solution on displaying an Error Icon in a cell of a RADGridView i.e. like in SQL Management Studio when a certain criteria is met.
Scenario 1: Validate all cells in a row simultaneously
Scenario 2: Validate an individual cell

So here goes:
Solution 1: Validate all cells in a row simultaneously
Private Sub rgvSrcExtractFiles_RowValidating(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.RowValidatingEventArgs) Handles rgvSrcExtractFiles.RowValidating
    If TypeOf e.Row Is GridViewDataRowInfo Then
        For Each cell As GridViewCellInfo In e.Row.Cells
            Select Case cell.ColumnInfo.Name
                Case "FileDirectory"
                    If Not FileAcc.DirectoryExists(cell.Value) Then
                        cell.ErrorText = "Directory not found!"
                    ElseIf FileAcc.CountFilePrefixWithExt(cell.Value, e.Row.Cells("FilePrefix").Value, e.Row.Cells("FileExtension").Value) = 0 Then
                        cell.ErrorText = "No valid files found in directory!"
                    Else
                        cell.ErrorText = String.Empty
                    End If
                Case "FilePrefix"
                    If FileAcc.CountFilePrefix(e.Row.Cells("FileDirectory").Value, cell.Value) = 0 Then
                        cell.ErrorText = "Files not found!"
                    Else
                        cell.ErrorText = String.Empty
                    End If
                Case "FileExtension"
                    If FileAcc.CountFileExt(e.Row.Cells("FileDirectory").Value, cell.Value) = 0 Then
                        cell.ErrorText = "Files not found!"
                    Else
                        cell.ErrorText = String.Empty
                    End If
            End Select
        Next
    End If
End Sub



Solution 2: Validate an individual cell

Private Sub rgvSrcExtractFiles_CellValidating(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.CellValidatingEventArgs)  Handles rgvSrcExtractFiles.CellValidating
    Dim column As GridViewDataColumn = TryCast(e.Column, GridViewDataColumn)
    If TypeOf e.Row Is GridViewDataRowInfo AndAlso column IsNot Nothing Then
        Select Case column.Name
            Case "FileDirectory"
                If Not FileAcc.DirectoryExists(e.Value) Then
                    DirectCast(e.Row.Cells(e.ColumnIndex), GridViewCellInfo).ErrorText = "Directory not found!"
                ElseIf FileAcc.CountFilePrefixWithExt(e.Value, e.Row.Cells("FilePrefix").Value, e.Row.Cells("FileExtension").Value) = 0 Then
                    DirectCast(e.Row.Cells(e.ColumnIndex), GridViewCellInfo).ErrorText = "Files not found!"
                Else
                    DirectCast(e.Row.Cells(e.ColumnIndex), GridViewCellInfo).ErrorText = String.Empty
                End If
            Case "FilePrefix"
                If FileAcc.CountFilePrefix(e.Row.Cells("FileDirectory").Value, e.Value) = 0 Then
                    DirectCast(e.Row.Cells(e.ColumnIndex), GridViewCellInfo).ErrorText = "Files not found!"
                Else
                    DirectCast(e.Row.Cells(e.ColumnIndex), GridViewCellInfo).ErrorText = String.Empty
                End If
            Case "FileExtension"
                If FileAcc.CountFileExt(e.Row.Cells("FileDirectory").Value, e.Value) = 0 Then
                    DirectCast(e.Row.Cells(e.ColumnIndex), GridViewCellInfo).ErrorText = "Files not found!"
                Else
                    DirectCast(e.Row.Cells(e.ColumnIndex), GridViewCellInfo).ErrorText = String.Empty
                End If
        End Select
    End If
End Sub



AND TADA :                                                                        **** THE MAGIC ***** 

Private Sub rgvSrcExtractFiles_CellFormatting(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.CellFormattingEventArgs) Handles rgvSrcExtractFiles.CellFormatting
    Dim cell As GridDataCellElement = TryCast(e.CellElement, GridDataCellElement)
    If cell IsNot Nothing Then
        If cell.ContainsErrors Then
            'Uncomment to draw a red border around cell as well
            'cell.DrawBorder = True
            'cell.BorderBoxStyle = BorderBoxStyle.SingleBorder
            'cell.BorderWidth = 2
            'cell.BorderColor = Color.Red
            'cell.ImageAlignment = ContentAlignment.MiddleRight
 
            Dim prov As New ErrorProvider
            Dim conv As New ImageConverter
            cell.Image = conv.ConvertFrom(prov.Icon)
 
            cell.TextImageRelation = TextImageRelation.TextBeforeImage
            cell.ImageAlignment = ContentAlignment.MiddleRight
            cell.ImageLayout = ImageLayout.None
        Else
            'Resets the borders to the original value
            'cell.ResetValue(LightVisualElement.DrawBorderProperty, ValueResetFlags.Local)
            'cell.ResetValue(LightVisualElement.BorderBoxStyleProperty, ValueResetFlags.Local)
            'cell.ResetValue(LightVisualElement.BorderWidthProperty, ValueResetFlags.Local)
            'cell.ResetValue(LightVisualElement.BorderColorProperty, ValueResetFlags.Local)
 
            cell.Image = Nothing
        End If
    End If
End Sub

That's it folks. You can use EITHER Solution 1 or 2, but you have to include the magic irrespective of which one you choose.
Hope this saves you some hours. 

Sharing is Caring
The_O
Stefan
Telerik team
 answered on 27 Sep 2011
1 answer
118 views
How do you enable a pivot table with your control?
Stefan
Telerik team
 answered on 27 Sep 2011
1 answer
162 views
How can I highlight RadSplitButton to make it more visible  when focused. I tried setting up explicitly IsMouseOver = true on focus enter event, but it doesn't work. Is there any other way I can do it?

Thanks.
Stefan
Telerik team
 answered on 27 Sep 2011
1 answer
216 views
There is a property for the main masterviewtemplate of a RadGridView to set the rows to auto size if you have a column's WordWrap turned on (i.e., this.radGridViewRequests.AutoSizeRows = true ).  This works slick.
BUT, for a child template there is no such property to AutoSizeRows if you have a column's WordWrap turned on.  So what is one supposed to do to get the child template rows to resize properly?
Stefan
Telerik team
 answered on 27 Sep 2011
Narrow your results
Selected tags
Tags
GridView
General Discussions
Scheduler and Reminder
Treeview
Dock
RibbonBar
Themes and Visual Style Builder
ChartView
Calendar, DateTimePicker, TimePicker and Clock
DropDownList
Buttons, RadioButton, CheckBox, etc
ListView
ComboBox and ListBox (obsolete as of Q2 2010)
Form
Chart (obsolete as of Q1 2013)
PageView
MultiColumn ComboBox
TextBox
RichTextEditor
PropertyGrid
Menu
RichTextBox (obsolete as of Q3 2014 SP1)
Panelbar (obsolete as of Q2 2010)
PivotGrid and PivotFieldList
Tabstrip (obsolete as of Q2 2010)
MaskedEditBox
PdfViewer and PdfViewerNavigator
CommandBar
ListControl
Carousel
GanttView
Diagram, DiagramRibbonBar, DiagramToolBox
Panorama
New Product Suggestions
VirtualGrid
Toolstrip (obsolete as of Q3 2010)
Label
AutoCompleteBox
Spreadsheet
ContextMenu
Panel
Visual Studio Extensions
TitleBar
SplitContainer
Documentation
Map
DesktopAlert
CheckedDropDownList
ProgressBar
MessageBox
TrackBar
Rotator
SpinEditor
CheckedListBox
StatusStrip
Wizard
CollapsiblePanel
LayoutControl
ShapedForm
SyntaxEditor
TextBoxControl
Conversational UI, Chat
DateTimePicker
TabbedForm
CAB Enabling Kit
WaitingBar
GroupBox
DataEntry
ScrollablePanel
ScrollBar
ImageEditor
Tools - VSB, Control Spy, Shape Editor
BrowseEditor
DataFilter
FileDialogs
ColorDialog
Gauges (RadialGauge, LinearGauge, BulletGraph)
ApplicationMenu
RangeSelector
CardView
WebCam
NavigationView
BindingNavigator
RibbonForm
Styling
Barcode
PopupEditor
TaskBoard
Callout
ColorBox
PictureBox
FilterView
Accessibility
VirtualKeyboard
DataLayout
Licensing
ToastNotificationManager
ValidationProvider
CalculatorDropDown
Localization
TimePicker
BreadCrumb
ButtonTextBox
FontDropDownList
BarcodeView
Overlay
Security
LocalizationProvider
Dictionary
TreeMap
StepProgressBar
SplashScreen
Flyout
Separator
SparkLine
ToolbarForm
NotifyIcon
DateOnlyPicker
AI Coding Assistant
Rating
TimeSpanPicker
Calculator
OfficeNavigationBar
TaskbarButton
HeatMap
SlideView
PipsPager
AIPrompt
TaskDialog
TimeOnlyPicker
SpeechToTextButton
SmartPasteButton
+? more
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?