We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

AutoComplete.DataSource - Reset technique

Thread ID:

Created:

Updated:

Platform:

Replies:

667 Jul 24,2002 01:07 AM UTC Jul 26,2002 07:01 PM UTC Windows Forms 2
loading
Tags: Tools
Sam Horton
Asked On July 24, 2002 01:07 AM UTC

I have the following code which runs normally the first time it is invoked but fails on any subsequent call. (User is selecting a field name sans '_' in one combo box, a textbox with an autofill needs to be changed as a result...) The ArrayList() is clean.... What did I miss? 'Invoked when a combo box specifying a valid column is changed to re-populate autocomplete lookup list Private iTotalRowCount As Integer, iRowCount As Integer, m_LastItem As String, m_TempItem As String Public Sub FillAutoCompleteListByColName(ByVal dv As DataView, ByVal sColName As String, ByRef AutoCtl As Syncfusion.Windows.Forms.Tools.AutoComplete) Dim tmpArray As New ArrayList() sColName = sColName.Replace(" ", "_") dv.Sort = sColName m_LastItem = String.Empty iTotalRowCount = dv.Count If iTotalRowCount > 0 Then For iRowCount = 0 To iTotalRowCount - 1 If (dv(iRowCount).Item(sColName).ToString <> String.Empty) Then m_TempItem = dv(iRowCount).Item(sColName).ToString If m_TempItem <> m_LastItem Then tmpArray.Add(m_TempItem) m_LastItem = m_TempItem End If End If Next End If Try AutoCtl.DataSource = tmpArray ' Line 202 above Catch E As Exception 'MsgBox(E.ToString) Console.WriteLine(E.ToString) End End Try 'Runs fine first time, autocomplete works great... Second time (or any subsequent) I see... Syncfusion.Windows.Forms.Tools.DataSourceException: There was a problem with the specified DataSource. Please check the InnerException for more details. ---> System.NullReferenceException: Object reference not set to an instance of an object. at System.Data.DataTable.InsertRow(DataRow row, Int32 proposedID, Int32 pos) at System.Data.DataTable.AddRow(DataRow row, Int32 proposedID) at System.Data.DataRowCollection.Add(DataRow row) at Syncfusion.Windows.Forms.Tools.AutoComplete.SetTableData() --- End of inner exception stack trace --- at Syncfusion.Windows.Forms.Tools.AutoComplete.SetTableData() at Syncfusion.Windows.Forms.Tools.AutoComplete.set_DataSource(Object value) at TargetTrak_Pro.QuickFilter.FillAutoCompleteListByColName(DataView dv, String sColName, AutoComplete& AutoCtl) in C:\Documents and Settings\Sam\My Documents\Visual Studio Projects\TargetTrak_Pro\QuickFilter.vb:line 202 The program '[3096] TargetTrak_Pro.exe' has exited with code 0 (0x0).

Sam Horton
Replied On July 24, 2002 11:17 AM UTC

> I have the following code which runs normally the first time it is invoked but fails on any subsequent call. (User is selecting a field name sans '_' in one combo box, a textbox with an autofill needs to be changed as a result...) > > The ArrayList() is clean.... What did I miss? > > 'Invoked when a combo box specifying a valid column is changed to re-populate autocomplete lookup list > Private iTotalRowCount As Integer, iRowCount As Integer, m_LastItem As String, m_TempItem As String > Public Sub FillAutoCompleteListByColName(ByVal dv As DataView, ByVal sColName As String, ByRef AutoCtl As Syncfusion.Windows.Forms.Tools.AutoComplete) > Dim tmpArray As New ArrayList() > sColName = sColName.Replace(" ", "_") > dv.Sort = sColName > m_LastItem = String.Empty > > iTotalRowCount = dv.Count > If iTotalRowCount > 0 Then > For iRowCount = 0 To iTotalRowCount - 1 > If (dv(iRowCount).Item(sColName).ToString <> String.Empty) Then > m_TempItem = dv(iRowCount).Item(sColName).ToString > If m_TempItem <> m_LastItem Then > tmpArray.Add(m_TempItem) > m_LastItem = m_TempItem > End If > End If > Next > End If > > Try > AutoCtl.DataSource = tmpArray > ' Line 202 above > Catch E As Exception > 'MsgBox(E.ToString) > Console.WriteLine(E.ToString) > End > End Try > > 'Runs fine first time, autocomplete works great... Second time (or any subsequent) I see... > > Syncfusion.Windows.Forms.Tools.DataSourceException: There was a problem with the specified DataSource. Please check the InnerException for more details. ---> System.NullReferenceException: Object reference not set to an instance of an object. > at System.Data.DataTable.InsertRow(DataRow row, Int32 proposedID, Int32 pos) > at System.Data.DataTable.AddRow(DataRow row, Int32 proposedID) > at System.Data.DataRowCollection.Add(DataRow row) > at Syncfusion.Windows.Forms.Tools.AutoComplete.SetTableData() > --- End of inner exception stack trace --- > at Syncfusion.Windows.Forms.Tools.AutoComplete.SetTableData() > at Syncfusion.Windows.Forms.Tools.AutoComplete.set_DataSource(Object value) > at TargetTrak_Pro.QuickFilter.FillAutoCompleteListByColName(DataView dv, String sColName, AutoComplete& AutoCtl) in C:\Documents and Settings\Sam\My Documents\Visual Studio Projects\TargetTrak_Pro\QuickFilter.vb:line 202 > The program '[3096] TargetTrak_Pro.exe' has exited with code 0 (0x0). --update-- I have this working in a slightly different form, but if you have any recc. for an improvement or overlooked best approach I would appreciate the advice....... Private iTotalRowCount As Integer, iRowCount As Integer, m_LastItem As String, m_TempItem As String Public Sub FillAutoCompleteListByColNameWithBind(ByVal dv As DataView, ByVal sColName As String, ByRef bindTxtBox As Windows.Forms.TextBox) Dim tmpArray As New ArrayList() sColName = sColName.Replace(" ", "_") dv.Sort = sColName m_LastItem = String.Empty iTotalRowCount = dv.Count If iTotalRowCount > 0 Then For iRowCount = 0 To iTotalRowCount - 1 If (dv(iRowCount).Item(sColName).ToString.Trim <> String.Empty) Then m_TempItem = dv(iRowCount).Item(sColName).ToString If m_TempItem <> m_LastItem Then tmpArray.Add(m_TempItem) m_LastItem = m_TempItem End If End If Next End If tmpArray.TrimToSize() Try Dim newAutoCtl As New Syncfusion.Windows.Forms.Tools.AutoComplete() newAutoCtl.AutoSerialize = False newAutoCtl.BorderType = Syncfusion.Windows.Forms.Tools.AutoCompleteBorderTypes.Sizable newAutoCtl.CategoryName = sColName newAutoCtl.DataSource = tmpArray newAutoCtl.SetAutoComplete(bindTxtBox, Syncfusion.Windows.Forms.Tools.AutoCompleteModes.AutoSuggest) Catch E As Exception 'MsgBox(E.ToString) Console.WriteLine(E.ToString) End End Try End Sub

Davis Jebaraj [Syncfusion]
Replied On July 26, 2002 07:01 PM UTC

Hi Sam, I will see what can be done to prevent this problem and get back to you. Thank you for your patience. Regards, Davis

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;