I have a tabcontrol that I had originally designed with three tabs. Now
we don't always need the three, so I removed the third one and only add
it at runtime as and when needed. However, since removing the third tab
I keep running into weird problems whenever I'm working with only two tabs:
Tabsheet1 contains a readonly datagrid. Tabsheet2 contains input boxes
etc. bound to an SQL Server database table via a dataview (which is also
the datasource for the grid on tabsheet1). Now when I add a new record,
enter some data into the input boxes and try to switch to tabsheet1 I
keep getting an "object reference not set" error message and the
debugger stops at application.run. Also, when I try to save the changes
(which afterwards involves switching to the grid) rather than switch
tabs without saving, I get a similar error message but the debugger
stops in
TabControl1.SelectedIndex := 0;
even though immediately before I can display the Tabcontrol1.Tabcount
and Tabcontrol1.SelectedIndex successfully. In the first case (i.e.
switching tabs without saving) I can see the grid except for the last,
new row of which there is only the indicator visible but nothing more.
On the odd occasion I've also had a problem with adding the new record:
I can then only fill in the first three input boxes but do nothing
afterwards, neither tab to the next field nor click any button or click
the mouse pointer into the next field, but there's no error message either.
And just now, I've had no problems switching tabs, but that was once in
about 100 attempts.
As I said, as soon as I have all three tabs displayed, there's no
problem whatsoever - I can save, I can change tabs, everything's fine.
I've put conditions of tabcount and/or selectedindex into all places
that refer to the non-existent tabs so these parts can't interfere when
the third tab isn't present.
What could be the cause?
TIA.
Brigitte
> I have a tabcontrol that I had originally designed with three tabs. Now
> we don't always need the three, so I removed the third one and only add
> it at runtime as and when needed. However, since removing the third tab
> I keep running into weird problems whenever I'm working with only two tabs:
Can you create a simple example which illustrates the problem?
Also have you tried checking the call stack at the point you get the
exception?
--
Marc Rohloff [TeamB]
marc -at- marc rohloff -dot- com