Error while navigating

soniix

Member
Joined
Apr 18, 2003
Messages
19
hi there i got another problem :(

let me explain i have a search form with some text boxes and a datagrid. ok if i type some string into one textbox and then press F2 it searches in the databes for the string and then commit the result back and i load the results into the datagrid so far so good :)

if i click on a grid row it first clears the databindings from all textboxes and then binds the textboxes again to the data (most of em are text databindings) then i can click around the grid and get the actual data to the textboxes BUT if i bind the Tag property of a textbox to some data like an ID and then click around i get an error like this

An unhandled exception of type System.NullReferenceException occurred in system.windows.forms.dll

and then the program halts at the class definition of the main form :( (Public class form2)

how can i fix this?

i also noticed that if i bind data to the text property of a textbox and if i type this textbox1.databindings.add("text",datasource,"ID") then this error occurs too if i change text to Text the error wont occur
 
Examine the line of code in which the error occurs. One of the variables there is supposed to point to an object, but the object has not been instantiated so far.

(Thats the typical reason behind the NullReferenceException)
 
hehe i know the line of code its the line where i bind the tag property from a textbox to data

as long as i bind the text property to data it all works fine i can navigate in the grid up and down this error occurs only if i bind a tag property to any of the textboxes :confused:

ok heres the working example

Code:
            stlaenge.DataBindings.Clear()
            stlaenge.DataBindings.Add("Text", datasource, "StammTeilLaenge")
            stdim.DataBindings.Clear()
            stdim.DataBindings.Add("Text", datasource, "StammDimension")
            stwst.DataBindings.Clear()
            stwst.DataBindings.Add("Text", datasource, "StammWerkstoff")

and here is the not working example

Code:
            stlaenge.DataBindings.Clear()
            stlaenge.DataBindings.Add("Tag", datasource, "StammTeilLaenge")
            stdim.DataBindings.Clear()
            stdim.DataBindings.Add("Text", datasource, "StammDimension")
            stwst.DataBindings.Clear()
            stwst.DataBindings.Add("Text", datasource, "StammWerkstoff")
 
Originally posted by Heiko
And you are sure the Tag property is not nothing ?

no, the value of the data is 1, anyways i can bind the text property to the same data and all works, the error occurs only when i bind the tag property of the text box

i forgot, i can bind the tag property the error occours then only if i navigate trough the grid up and down, so the tag properties changes every time
 
Last edited by a moderator:
Back
Top