Results 1 to 4 of 4

Thread: Textbox with Autocomplete on Windows Phone 7 (Facebook style)

  1. #1
    Join Date
    Oct 2010
    Posts
    53

    Textbox with Autocomplete on Windows Phone 7 (Facebook style)

    I have observed the Windows Phone 7 Beta SDK and i am having a simple query or you may consider it as a suggestion as well. Actually is it possible to have a Textbox with an autocomplete property on Windows Phone 7. If you are not getting my query then it would be better to checkout the facebook where the textbox reacts in the manner which i am talking about or there would be an additional search button next to the Textbox.

  2. #2
    Join Date
    Oct 2008
    Posts
    421

    Re: Textbox with Autocomplete on Windows Phone 7 (Facebook style)

    I guess my problem is much similar with yours. I am having a ListBox which has been composed of a datatable with two columns, one with primary key (ValueMember), the other with the display name (DisplayMember).
    The goal is to achieve the autocompletion textbox via the list.
    Following code level where you can see that the research is based on what you type. Only problem i am facing while concatenating my textbox with autocomplete but still it remains white. Finally when I apply this same code then everything works fine, actually I do not know how to display text to return.
    Code:
    Private Sub Form1_Load (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 
    MyConn.Open () 
    MyComm.CommandText = CommandType.Text 
    MyComm.CommandText = "SELECT param1, param2, param3 from student order by colname" 
    MyCurser = MyComm.ExecuteReader 
    
    data.Columns.Add ("C1") 
    data.Columns.Add ("C2", GetType (String)) 
    While MyCurser.Read () = True 
    data.Rows.Add (MyCurser.GetDecimal (0), MyCurseur.GetString (1)) 
    End While 
    List1.DataSource = data 
    List1.ValueMember = "C1" 
    List1.DisplayMember = "C2" 
    
    MyCurser.Close () 
    End Sub 
    Private Sub Text1_TextChanged (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Text1.TextChanged 
    
    Try 
    Then if AutoComplete 
    Sun TextEntered As String = Text1.Text 
    Sun iIndex As Integer = List1.FindString (Text1.Text.Trim ()) 
    If iIndex> = 0 Then 
    AutoComplete = False 
    List1.SelectedIndex = iIndex 
    List1.TopIndex = iIndex 
    Text1.Text = dt.DisplayExpression () 'List1.Columns (0). Text 
    AutoComplete = True 
    Text1.Select (TextEntered.Length, Text1.Text.Length) 
    Else 
    List1.SelectedIndex = -1 
    End If 
    End If 
    Catch ex As Exception 
    MsgBox (ex.Message) 
    End Try 
    End Sub 
    Private Sub Text1_KeyDown (ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Text1.KeyDown 
    
    AutoComplete = e.KeyCode <> Keys.Delete And e.KeyCode <> Keys.Back 
    
    End Sub

  3. #3
    Join Date
    Oct 2008
    Posts
    454

    Re: Textbox with Autocomplete on Windows Phone 7 (Facebook style)

    I think I have got it what you want to do. Add the following code in the Text1 autocomplete, content of List1. Thus, typing a few letters will offer you a list that will appear below it and that will contain the content of List1 is what you have typed earlier in the text1. If this is what you seek, you no longer need the procedure Text1_TextChanged, everything will be done automatically.
    Code:
    Private Sub Form1_Load (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase. Load 
    MyConn.Open () 
    MyComm.CommandText = CommandType.Text 
    MyComm.CommandText = "SELECT param1, param2, param3 from student order by colname" 
    Mycurser = MyComm.ExecuteReader 
    
    data.Columns.Add ("C1")
    data.Columns.Add ("C2", GetType (String)) 
    
    While MyCurser.Read () = True 
    dt.Rows.Add (MyCurser.GetDecimal (0), MyCurser.GetString (1)) 
    End While 
    
    List1.DataSource = dt 
    List1.ValueMember = "C1" 
    List1.DisplayMember = "C2" 
    
    MyCurser.Close () 
    'Start Editing Code 
    Sun Pass As New System.Windows.Forms.AutoCompleteStringCollection 
    For Each Str As String In List1.Items 
    col.Add (Str) 
    Next 
    Text1.AutoCompleteCustomSource = col 
    Text1.AutoCompleteMode = AutoCompleteMode.Suggest 
    Text1.AutoCompleteSource = AutoCompleteSource.CustomSource 
    'End of code change 
    End Sub

  4. #4
    Join Date
    Oct 2008
    Posts
    401

    Re: Textbox with Autocomplete on Windows Phone 7 (Facebook style)

    Here i have given the syntax to declare the textbox with an Autocomplete property. If you are using .VB then the code is as follows.
    Code:
    <ThemeableAttribute(False)> _
    Public Overridable Property AutoCompleteType As AutoCompleteType
    	Get
    	Set
    
    <asp:TextBox AutoCompleteType="AutoCompleteType" />
    If you are using "C#" then :
    Code:
    [ThemeableAttribute(false)]
    public virtual AutoCompleteType AutoCompleteType { get; set; }
    
    <asp:TextBox AutoCompleteType="AutoCompleteType" />
    If you are using C++ then :
    Code:
    [ThemeableAttribute(false)]
    public:
    virtual property AutoCompleteType AutoCompleteType {
    	AutoCompleteType get ();
    	void set (AutoCompleteType value);
    }
    
    <asp:TextBox AutoCompleteType="AutoCompleteType" />
    If you are using F# then :
    Code:
    [<ThemeableAttribute(false)>]
    abstract AutoCompleteType : AutoCompleteType with get, set
    [<ThemeableAttribute(false)>]
    override AutoCompleteType : AutoCompleteType with get, set
    
    <asp:TextBox AutoCompleteType="AutoCompleteType" />

Similar Threads

  1. Replies: 5
    Last Post: 30-10-2011, 08:54 AM
  2. can I Switch back to old style Facebook chat box
    By Bikas in forum Technology & Internet
    Replies: 3
    Last Post: 23-09-2011, 08:17 PM
  3. How to use the Facebook developer with the windows phone 7
    By Dakshina in forum Portable Devices
    Replies: 3
    Last Post: 27-10-2010, 05:14 AM
  4. Replies: 2
    Last Post: 20-08-2010, 01:23 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,954,757.19637 seconds with 16 queries