Re: An object reference is required for the non-static field, method, or property message



On Jun 18, 5:58 pm, "Dave" <d...@xxxxx> wrote:

The problem is with my listbox on the form.
I am trying to run 2 threads simulataneously an update two different listbox
controls but my functions are complaining that the listbox doesn't have an
object reference,  my listboxes were created by the ide and drawn on the
form at design time.
How can I give my listbox a reference?

Very simple: make methods you use as thread entry points (in your
case, AddItems1 and AddItems2) non-static.

In addition to that, you cannot call (most) methods and properties on
Windows Forms controls from any thread other than the one which had
created them. In your case, trying to add an item to the ListBox from
another thread will result in an exception. You can work around this
by using Control.Invoke and Control.BeginInvoke as needed - MSDN has
more details and examples, as usual.
.



Relevant Pages

  • Re: NEWBIE - Displaying Selection of Listbox Item
    ... >> I have a Listbox that is populated from a SQL Statement. ... >> I have the datatext and datavalue fields both set to the same field in my ... >> Object reference not set to an instance of an object. ... >> End Sub ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: NEWBIE - Displaying Selection of Listbox Item
    ... >> I have a Listbox that is populated from a SQL Statement. ... >> I have the datatext and datavalue fields both set to the same field in ... >> Object reference not set to an instance of an object. ... >> End Sub ...
    (microsoft.public.dotnet.framework.aspnet)
  • listboxes
    ... im trying to transfer data from a listbox to a textbox. ... Object reference not set to an instance of an object. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Dynamic dropdownlist problem
    ... and still got the "Object reference not set to an ... Each page reload rebinds the ... listbox contents, so the value selected is lost during the postback - ... list if the dropdownlist selection is changed ie so if selecting an ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: ListBox index values
    ... Object reference not set to an instance of an object. ... "srini" wrote: ... > you can get the selected value of the listbox at the server side using ... >> Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ...
    (microsoft.public.dotnet.framework.aspnet)

Loading