Telerik Forums
UI for WinForms Forum
5 answers
195 views
Hi,

I was wondering if the solution I created below is the best way to do what I want.

I have a list that when the user types in, i'd like the suggestions to pop up, to suggest the items that begin with the text first, but then also include all other items that have that text within it below that.

i.e.
if the list is

aper

aaper

ape

per

pants per

aaa per


and the user types 'p' then I want the list to show

pants per

per

aaa per

aaper

ape

aper


when the user types 'pe' then i want the list to show

per

aaa per

aaper

ape

aper

pants per



when the user types 'per' then i want the list to show

per

aaa per

aaper

aper

pants per


My ApplyFilterToDropDown is an almost copy of the Telerik one, but injecting my comparer instead. I had to do this because if I just set the ItemsSortComparer to mine, then called the base.ApplyFilterToDropDown it always got wiped out, so I resorted to this.

Imports Telerik.WinControls.UI
  
Public Class Form7
    Inherits System.Windows.Forms.Form
  
    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    End Sub
  
    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer
  
    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Dim RadListDataItem1 As Telerik.WinControls.UI.RadListDataItem = New Telerik.WinControls.UI.RadListDataItem()
        Dim RadListDataItem2 As Telerik.WinControls.UI.RadListDataItem = New Telerik.WinControls.UI.RadListDataItem()
        Dim RadListDataItem3 As Telerik.WinControls.UI.RadListDataItem = New Telerik.WinControls.UI.RadListDataItem()
        Dim RadListDataItem4 As Telerik.WinControls.UI.RadListDataItem = New Telerik.WinControls.UI.RadListDataItem()
        Dim RadListDataItem5 As Telerik.WinControls.UI.RadListDataItem = New Telerik.WinControls.UI.RadListDataItem()
        Dim RadListDataItem6 As Telerik.WinControls.UI.RadListDataItem = New Telerik.WinControls.UI.RadListDataItem()
        Me.RadDropDownList1 = New Telerik.WinControls.UI.RadDropDownList()
        CType(Me.RadDropDownList1, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'RadDropDownList1
        '
        Me.RadDropDownList1.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend
        Me.RadDropDownList1.DropDownAnimationEnabled = True
        RadListDataItem1.Text = "aper"
        RadListDataItem1.TextWrap = True
        RadListDataItem2.Text = "aaper"
        RadListDataItem2.TextWrap = True
        RadListDataItem3.Text = "ape"
        RadListDataItem3.TextWrap = True
        RadListDataItem4.Text = "per"
        RadListDataItem4.TextWrap = True
        RadListDataItem5.Text = "pants per"
        RadListDataItem5.TextWrap = True
        RadListDataItem6.Text = "aaa per"
        RadListDataItem6.TextWrap = True
        Me.RadDropDownList1.Items.Add(RadListDataItem1)
        Me.RadDropDownList1.Items.Add(RadListDataItem2)
        Me.RadDropDownList1.Items.Add(RadListDataItem3)
        Me.RadDropDownList1.Items.Add(RadListDataItem4)
        Me.RadDropDownList1.Items.Add(RadListDataItem5)
        Me.RadDropDownList1.Items.Add(RadListDataItem6)
        Me.RadDropDownList1.Location = New System.Drawing.Point(93, 126)
        Me.RadDropDownList1.Name = "RadDropDownList1"
        Me.RadDropDownList1.ShowImageInEditorArea = True
        Me.RadDropDownList1.Size = New System.Drawing.Size(106, 20)
        Me.RadDropDownList1.TabIndex = 1
        Me.RadDropDownList1.ThemeName = "ControlDefault"
        '
        'Form7
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(292, 273)
        Me.Controls.Add(Me.RadDropDownList1)
        Me.Name = "Form7"
        Me.Text = "Form7"
        CType(Me.RadDropDownList1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)
        Me.PerformLayout()
  
    End Sub
    Friend WithEvents RadDropDownList1 As Telerik.WinControls.UI.RadDropDownList
  
  
    Public Class CustomAutoCompleteSuggestHelper
        Inherits AutoCompleteSuggestHelper
        Public Sub New(element As RadDropDownListElement)
            MyBase.New(element)
        End Sub
  
        Protected Overrides Function DefaultFilter(item As RadListDataItem) As Boolean
            Return item.Text.ToLower().Contains(Me.Filter.ToLower())
        End Function
  
        Public Overrides Sub AutoComplete(e As KeyPressEventArgs)
            MyBase.AutoComplete(e)
            If Me.DropDownList.Items.Count > 0 Then
                'Me.DropDownList.SelectedIndex = Me.DropDownList.FindString(Me.Filter)
            End If
        End Sub
  
        Private mFilter As String = String.Empty
        Protected Overrides ReadOnly Property Filter As String
            Get
                Return mFilter
            End Get
        End Property
  
        Public Overrides Sub ApplyFilterToDropDown(filter As String)
            Static filterFirstComparer As ListItemFilterAscendingComparer
            mFilter = filter
            If String.IsNullOrEmpty(filter) Then
                MyBase.ApplyFilterToDropDown(filter)
                Return
            End If
            With Me.DropDownList.ListElement
                .SelectionMode = SelectionMode.None
                .BeginUpdate()
                .Filter = Nothing
                .Filter = AddressOf DefaultFilter
                .SortStyle = Telerik.WinControls.Enumerations.SortStyle.Ascending
            End With
            ' will move all items that begin with the filter, to the top of the list
            If filterFirstComparer Is Nothing Then
                filterFirstComparer = New ListItemFilterAscendingComparer With {.filter = filter}
            Else
                filterFirstComparer.filter = filter
            End If
            Me.DropDownList.ListElement.ItemsSortComparer = filterFirstComparer
            Me.DropDownList.ListElement.EndUpdate()
        End Sub
  
        ''' <summary>
        ''' This class is used to compare data items when sorting in ascending order.
        ''' </summary>
        Private Class ListItemFilterAscendingComparer
            Implements System.Collections.Generic.IComparer(Of RadListDataItem)
  
            Public Property filter As String
  
            Public Overridable Function Compare(x As RadListDataItem, y As RadListDataItem) As Integer Implements System.Collections.Generic.IComparer(Of Telerik.WinControls.UI.RadListDataItem).Compare
                Dim ignoreCase = False
                If x.Owner IsNot Nothing Then
                    ignoreCase = Not x.Owner.CaseSensitiveSort
                End If
                Dim xStart = x.Text.StartsWith(filter, System.StringComparison.InvariantCultureIgnoreCase)
                Dim yStart = y.Text.StartsWith(filter, System.StringComparison.InvariantCultureIgnoreCase)
                If xStart AndAlso Not yStart Then
                    Return -1
                ElseIf yStart AndAlso Not xStart Then
                    Return 1
                End If
                Return String.Compare(x.Text, y.Text, ignoreCase)
            End Function
  
        End Class
    End Class
  
    Private Sub Form7_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        RadDropDownList1.AutoCompleteMode = Windows.Forms.AutoCompleteMode.SuggestAppend
        RadDropDownList1.DropDownListElement.AutoCompleteSuggest = New CustomAutoCompleteSuggestHelper(RadDropDownList1.DropDownListElement)
    End Sub
End Class


Peter
Telerik team
 answered on 28 May 2012
1 answer
150 views
Telerik controls v2010.1.10.504

The default behavior in a textbox column in a gridview is to have the text auto-selected when the cell is clicked. We have a requirement to override that behavior because typing can overwrite the entire contents, which our users don't want.

Unfortunately, if I do it via the CellFormatting event, then a race condition occurs if I manually try to select all the text and it becomes difficult to "Select All" to copy the cell contents. I have the CellClick clearing the text fine, it's actually when the embedded control is clicked in the cell which I'm unable to override.

I could only find the "EditorRequired" event as being fired when the GridViewTextBoxColumn is clicked (not the cell, but the embedded control in the cell), but at that time the ActiveEditor is not set, so I'm unable to access the underlying control and "Select(0,0)".

Please tell me how to override the default behavior.

Thank you.

Here is a sample code slice from the CellClick handler so you can see what I'm doing:
if ("GridViewTextBoxColumn" == ((Telerik.WinControls.UI.GridDataCellElement)(sender)).GridControl.CurrentColumn.GetType().Name)
{
    RadTextBoxEditor rtbe = ((Telerik.WinControls.UI.GridDataCellElement)(sender)).GridControl.ActiveEditor as RadTextBoxEditor;
    if (null != rtbe)
    {
        RadTextBoxEditorElement tbElement = (RadTextBoxEditorElement)rtbe.EditorElement;
        tbElement.Select(0, 0);
    }
}
Svett
Telerik team
 answered on 28 May 2012
4 answers
115 views
If I export HTML the output isn't formatted in any way and therefore an "unreadable" long chunk of text. Is it possible to get a formatted output without having to write a format proc myself (or use an external proc)?
Svett
Telerik team
 answered on 28 May 2012
2 answers
346 views
Hi,

I've been looking at the the events under Misc and I can't seem to find the TimelineViewClick?
http://screencast.com/t/AGYafvBjDcj

What event is fired when you click on timeline view?

Thanks
Ivan Todorov
Telerik team
 answered on 28 May 2012
2 answers
108 views
Hello all,

The first column in our grid contains checkboxes.  Clicking on them doesn't toggle between checked and unchecked as though they're read-only.


I can see no settings that indicate the column isn't anything other than editable.

HeaderGridview.Rows[0].Cells[0].ReadOnly = false

I tried to get round it by capturing an event and toggling it in code but the CellClick doesn't fire if you click a cell containing a checkbox and the mousedown event doesn't tell you which column you clicked on. 

I did post this question to support but just got the "can you send us a project" response which I don't have the time to do so i'm posting the question to the wider world.
Matthew
Top achievements
Rank 1
 answered on 28 May 2012
14 answers
441 views

Hi

I have tried change Microsoft combobox to Telerik new drop down list.

I have used this code to populate Microsoft combobox:

1.cbKlien.Items.Clear(); 
2.var c =bS.view_Trans_Order_Custs.OrderBy(i => i.CustomerCode).Select( 
4.      i => new {i.CustomerCode, i.CompleteCustomerName});
5. 
6.cbKlien.Items.AddRange(c.ToArray()); 
7.cbKlien.DisplayMember = "CustomerCode";

It worked and was very fast.

But when I have added telerik drop down list I have can not populate using the some code :( I have received errors:

1.Error   1   The best overloaded method match for 'Telerik.WinControls.UI.RadListDataItemCollection.AddRange(System.Collections.Generic.IEnumerable<Telerik.WinControls.UI.RadListDataItem>)' has some invalid arguments c:\Users\PLRoStu\Documents\Visual Studio 2008\Projects\100924 ZlecTrans Test od Telerik\ZlecTransp001\fMain.cs  219 10  Zlecenia transportowe

1.Error   2   Argument '1': cannot convert from 'AnonymousType#1[]' to 'System.Collections.Generic.IEnumerable<Telerik.WinControls.UI.RadListDataItem>'   c:\Users\PLRoStu\Documents\Visual Studio 2008\Projects\100924 ZlecTrans Test od Telerik\ZlecTransp001\fMain.cs  219 34  Zlecenia transportowe

This error was on this line:

1.ddlKlien.Items.AddRange(c.ToArray());

Of course I can populate using for but it very slow:

1.ddlKlien.Items.Clear();
2.        var c = dbS.view_Trans_Order_Custs.OrderBy(i => i.CustomerCode).Select(
3.              i => new {i.CustomerCode, i.CompleteCustomerName});
4.          
5.        for (int x = 0; x < c.ToArray().Length; x++) ddlKlien.Items.Add(c.ToArray()[x].CustomerCode);
6.        //ddlKlien.Items.AddRange(c.ToArray());
7.        ddlKlien.DisplayMember = "CustomerCode";

Could you help me correct my code for fast speed?

Qaiser
Top achievements
Rank 1
 answered on 27 May 2012
1 answer
145 views

I have 2 tables in database. strProductID  is primary key in table tblICInventory and strProductID   is reference key in tblICInventoryStockTotal. I want to show strProductID  but it couldn't show data in the Column tblICInventory.strProductID . Please help me !


void AddItemToMultiColumnCombobox()
        {
            System.Data.OleDb.OleDbConnection con = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + System.IO.Path.GetFullPath("../../Database//Demo2.mdb"));
            con.Open();
            OleDbCommand com = new OleDbCommand("select [tblICInventory].[strProductID] ,memDescription,dblUnitsInStock,dblUnitsAllocated,curSalesPrice,strWarehouseID from tblICInventory,tblICInventoryStockTotal where  tblICInventory.strProductID = tblICInventoryStockTotal.strProductID ", con);
 
            OleDbDataAdapter oleda = new OleDbDataAdapter();
            oleda.SelectCommand = com;
            DataSet ds = new DataSet();
            oleda.Fill(ds);
            GridViewMultiComboBoxColumn col = new GridViewMultiComboBoxColumn();
            col.DataSource = ds.Tables[0].DefaultView;
            col.DisplayMember = "tblICInventory.strProductID";
            col.ValueMember = "tblICInventory.strProductID";
            col.Width = 100;
            col.HeaderText = "Item No";
            this.radGridViewDetail.Columns.RemoveAt(1);
            this.radGridViewDetail.Columns.Insert(1, col);
            col.AutoCompleteMode = AutoCompleteMode.None;
 
            col.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDown;
            this.radGridViewDetail.CellBeginEdit += new GridViewCellCancelEventHandler(radGridViewDetail_CellBeginEdit);
        }
 
        bool isColumnAdded;
        void radGridViewDetail_CellBeginEdit(object sender, GridViewCellCancelEventArgs e)
        {
            if (this.radGridViewDetail.CurrentColumn is GridViewMultiComboBoxColumn)
            {
                if (!isColumnAdded)
                {
                    isColumnAdded = true;
                    RadMultiColumnComboBoxElement editor = (RadMultiColumnComboBoxElement)this.radGridViewDetail.ActiveEditor;
                    editor.EditorControl.MasterTemplate.AutoGenerateColumns = false;
                    editor.EditorControl.Columns.Add(new GridViewTextBoxColumn("tblICInventory.strProductID"));
                    editor.EditorControl.Columns.Add(new GridViewTextBoxColumn("memDescription"));
                    editor.EditorControl.Columns.Add(new GridViewTextBoxColumn("dblUnitsInStock"));
                    editor.EditorControl.Columns.Add(new GridViewTextBoxColumn("dblUnitsAllocated"));
                    editor.EditorControl.Columns.Add(new GridViewTextBoxColumn("curSalesPrice"));
                    editor.EditorControl.Columns.Add(new GridViewTextBoxColumn("strWarehouseID"));
                    editor.EditorControl.Columns[0].HeaderText = "Item No";
                    editor.EditorControl.Columns[1].HeaderText = "Description";
                    editor.EditorControl.Columns[2].HeaderText = "Stock";
                    editor.EditorControl.Columns[3].HeaderText = "Available";
                    editor.EditorControl.Columns[4].HeaderText = "Price";
                    editor.EditorControl.Columns[5].HeaderText = "Warehouse";
 
                    editor.AutoSizeDropDownToBestFit = true;
                }
            }
        }
Tan
Top achievements
Rank 1
 answered on 26 May 2012
3 answers
183 views
1. TextAlignment = ContentAlignment.MiddleCenter;
2. Bold = true;


        private void gv_CellFormatting(object sender, CellFormattingEventArgs e)
        {
            if (e.CellElement.ColumnInfo is GridViewCommandColumn)
            {
                int index = (int)e.CellElement.RowInfo.Cells[0].Value - 1;
                ((RadButtonElement)e.CellElement.Children[0]).TextAlignment = ContentAlignment.MiddleCenter;
                ((RadButtonElement)e.CellElement.Children[0]).Font.Bold = True;
            }  
        }

Please refer picture from attachment.
Who can help me? :)
Thank You.
Ivan Petrov
Telerik team
 answered on 25 May 2012
1 answer
76 views
Hi guys,

I'm trying to find out how to center headers.

if I create columns number, name, other, then they appear left justified in the designer.

I want them centered.

I can center in code when there are databound items.  I just can't find out how to center the headers in design mode with no items!!!

Colin.
Ivan Todorov
Telerik team
 answered on 25 May 2012
1 answer
102 views
Dear Support,

We use RadGridView with decimal column. If the user position to a cell with the keyboard and try to enter the value -123.456 the value will be 123.456. The '-' sign put the cell in edit mode but don't display in the cell? The demo have the same behavior (GridView - Columns - Column Types) with the decmal column. To be working the correct way, the user have to enter --123.456 by typing 2 times - sign...

Is there a way to trap the '-' sign and display as the current value of the cell?

Regards,
Nadia
Stefan
Telerik team
 answered on 25 May 2012
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)
Chart (obsolete as of Q1 2013)
Form
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
CommandBar
PdfViewer and PdfViewerNavigator
ListControl
Carousel
Diagram, DiagramRibbonBar, DiagramToolBox
GanttView
Panorama
New Product Suggestions
Toolstrip (obsolete as of Q3 2010)
VirtualGrid
AutoCompleteBox
Label
Spreadsheet
ContextMenu
Panel
Visual Studio Extensions
TitleBar
Documentation
SplitContainer
Map
DesktopAlert
ProgressBar
CheckedDropDownList
TrackBar
MessageBox
Rotator
SpinEditor
StatusStrip
CheckedListBox
LayoutControl
SyntaxEditor
Wizard
ShapedForm
TextBoxControl
Conversational UI, Chat
DateTimePicker
CollapsiblePanel
TabbedForm
CAB Enabling Kit
GroupBox
DataEntry
ScrollablePanel
ScrollBar
WaitingBar
ImageEditor
Tools - VSB, Control Spy, Shape Editor
BrowseEditor
DataFilter
ColorDialog
FileDialogs
Gauges (RadialGauge, LinearGauge, BulletGraph)
ApplicationMenu
RangeSelector
CardView
WebCam
BindingNavigator
PopupEditor
RibbonForm
Styling
TaskBoard
Barcode
Callout
ColorBox
PictureBox
FilterView
Accessibility
VirtualKeyboard
NavigationView
DataLayout
ToastNotificationManager
ValidationProvider
CalculatorDropDown
Localization
TimePicker
ButtonTextBox
FontDropDownList
Licensing
BarcodeView
BreadCrumb
Security
LocalizationProvider
Dictionary
Overlay
Flyout
Separator
SparkLine
TreeMap
StepProgressBar
SplashScreen
ToolbarForm
NotifyIcon
DateOnlyPicker
Rating
TimeSpanPicker
Calculator
OfficeNavigationBar
TaskbarButton
HeatMap
SlideView
PipsPager
AIPrompt
TaskDialog
TimeOnlyPicker
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?