Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2003
    Posts
    2

    Question Unanswered: VB - Listbox Refresh problem

    I connect an object to every line in the listboxes and the Comboboxes. The ToString() function of the object returns the text that ends up in the listbox. My problem is this.. When I update the object with new data, for example change the name, and the name is what is displayed in the list, the list doesnt get updated. I have tried to call different functions in the listbox, for example Update() and Refresh(), but i cant get the listbox to check the current value of ToString(). It seems to only check it when the object is added. So.. Do anyone know how to force the list to refresh the rows texts with the new values of the objects? Thank you!

  2. #2
    Join Date
    Feb 2002
    Posts
    2,232
    What language are you using ?

  3. #3
    Join Date
    Dec 2003
    Posts
    2
    Oups.. :-) Im using VB .Net

  4. #4
    Join Date
    Dec 2003
    Posts
    1

    Lightbulb sql3

    Dear Sir/Madam,

    Currently I am engaging in GIS (geographic information system) research work. My geodatabase design and implementation is based on dual systems. What is available around me is the .mdb and GIS applications. However, this can be also be done also within an integrated single database system (oracle spatial, informix or db2...etc), non of them are in PC or server.

    Now, I am so keen to implement my GIS project in an SQL3-styled application.
    Therfore, I would appreciate greately, if any body could offer me a guide on how to learn SQL3 practically either in the INTERNET or else.

    Bset Regards
    Ghebree
    Last edited by ghebree; 12-12-03 at 06:20.

  5. #5
    Join Date
    Jan 2004
    Posts
    2
    Originally posted by charlie78
    Oups.. :-) Im using VB .Net
    Can see that the first post was back in December03... did you resolve this problem? I've hit exactly the same setback, when the custom data object is added to the list box the ToString() method is called correctly so that the text is added without a problem. But, if the object is updated I can't get the list box to update the text by calling the ToString() method of the custom data object.

    Regards
    andy v

  6. #6
    Join Date
    Jan 2004
    Posts
    2
    Ok, here's a simple solution... Delete the object and then add it back to the ListBox. I'd like a neater way, but this works; and because we're adding the same reference object back into the ListBox, after deleting it, we're not affecting any variable(s) that have referenced that ListBox Item directly.

    Here's some code... just create a Windows app with one form and add a single ListBox to the form... On running the app two data items are added to the list box, double click one, or both, and the Text in the object is changed... this change is shown in the ListBox.

    ------------------------------------------------------------------------
    Public Class Form1
    Inherits System.Windows.Forms.Form

    Private Sub Form1_Load(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles MyBase.Load

    Dim objData1 As clsData = New clsData("Test Data 1")
    Dim objData2 As clsData = New clsData("Test Data 2")

    ListBox1.Items.Add(objData1)
    ListBox1.Items.Add(objData2)

    End Sub

    Private Sub ListBox1_DoubleClick(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles ListBox1.DoubleClick

    'Get the selected object from the list box
    Dim objData As clsData = _
    DirectCast(ListBox1.SelectedItem, clsData)

    Dim intIndex As Integer

    'Get the index of the selected object
    intIndex = ListBox1.SelectedIndex

    'Change the text within the data object
    objData.Data = objData.Data & "Text Changed..."

    'Remove the item from the list box using its index
    ListBox1.Items.RemoveAt(intIndex)

    'Add the data object to the List box at its old index
    ListBox1.Items.Insert(intIndex, objData)

    'Make the new addition the selected item
    ListBox1.SelectedIndex = intIndex

    End Sub

    End Class

    Public Class clsData
    'A simple data object used
    'For adding objects to the List Box
    Inherits Object

    Private m_strText As String

    Public Sub New(ByVal strText As String)
    MyBase.new()

    m_strText = strText
    End Sub

    Public Property Data() As String
    Get
    Return m_strText
    End Get
    Set(ByVal Value As String)
    m_strText = Value
    End Set
    End Property

    'The List Box calls this function when addint the object
    'to obtain the text that's to be displayed
    Public Overrides Function ToString() As String
    Return m_strText
    End Function

    End Class

    ------------------------------------------------------------------------

    Regards

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •