tabindex probs

  • Thread starter Thread starter EricJ
  • Start date Start date
E

EricJ

Hi all

we're having some problems controlling the tab order of a lot of controls
(on tab pages)
I was wondering if there are known bugs and/or workarounds for this?

last resort would be to capture the tab key and setting the focus manually

tnx in advance

eric
 
Hi Eric,

Very much knowed bug.

I have the idea, that with setting the tabpage names alphabetical is was
solved, but I am not sure of that, if you try it and it does or does not,
will you tell that, than if it does not I do not give that than stupid
answer anymore.

:-)

Cor
 
Hi Ken,

So this should be a generic solution for the problem if you name them
alphabetical?

Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim lambiek(Me.TabControl1.TabPages.Count - 1) As TabPage
Dim sidonia(Me.TabControl1.TabPages.Count - 1) As String
For i As Integer = TabControl1.TabPages.Count - 1 To 0 Step -1
lambiek(i) = TabControl1.TabPages(i)
sidonia(i) = TabControl1.TabPages.Item(i).name
TabControl1.TabPages.RemoveAt(i)
Next
lambiek.Sort(sidonia, lambiek)
For i As Integer = 0 To lambiek.Length - 1
TabControl1.TabPages.Add(lambiek(i))
Next
End sub

Cor
 
I am a colegue of Eric
I'm still having some problems w this sollution.
at the tabcontrol1.tabpages.removeat(i)
I get a "Object reference not set to an instance of an object."
What can I do about this?
 
Hi Kevin

Are you sure, because than you have placed that object already in the
tabpage array lambiek and his name in the array sidonia.

Cor
 
(he just left)
but yes its in that line after he knows the name of the tabpage and all, i
found it strange (to say the least).

Kevin will be following this up tomorrow (i have my own (web forms) troubles
;p)

tnx for the help

eric

ps: normally i'll be starting on a winforms project somwhere next month (the
sooner the better ;) ), expect more of me then.
 
Hi,

when i put the code in a button he runs the code right until the last
tabpage and then he gives the same mistake "Object reference not set to an
instance of an object.". while the last tabpage that he should remove is
still on the screen.


Kevin
 
Hi Kevin,

It is weird, I tried it also now in a button, it was as Ken stated in the
load event, and with the second click I get that error.

And strange is that when I change it in this it works.

Will you tell if it works with you also after this change?

TabControl1.TabPages.Remove(lambiek(i))

Cor
 
Hi Cor,

I find it also very wierd but when I changed the code he still gives me the
same error.

Kevin
 
Hi Kevin,

Paste that piece how you used not than back in including the button (first
to a notepath you know and than copy paste in the message, than I place that
in my sample and look also)

Cor
 
Hi Cor,
Here is my code but I don't think that it is different than yours.

Try
Dim lambiek(Me.TabControl1.TabPages.Count - 1) As TabPage

Dim sidonia(Me.TabControl1.TabPages.Count - 1) As String

For i As Integer = TabControl1.TabPages.Count - 1 To 0 Step -1

lambiek(i) = TabControl1.TabPages(i)

sidonia(i) = TabControl1.TabPages.Item(i).Name

TabControl1.TabPages.Remove(lambiek(i))

Next

lambiek.Sort(sidonia, lambiek)

For i As Integer = 0 To lambiek.Length - 1

TabControl1.TabPages.Add(lambiek(i))

Next

Catch ex As Exception

MessageBox.Show(ex.Message)

End Try

Kevin
 
Hi Kevin,
I cannot bring it down.

It runs if 1 push 10 times on the button.

What are the names of the tabpages you are using?

Cor
 
Hi Cor,

The names of the tabpages I use are ATabpage1, BTabpage7, CTabpage4,
DTabpage3, ETabpage2, FTabpage8, GTabpage6, HTabpage5.

Kevin
 
that would be visual studio 2003 framework 1.1
he is working on a win xp home (might do something?)

eric
 
Hi Eric,

Did you try it, I asked it to CJ also, because it does work in all
circumstances (also his code) with me.

I really do not understand this.

Cor
 
nope same strange errors
there are a lot of things happening on these tab pages leave lost focus ..
controls ...
so many things that could go wrong :(

kevin can try the alternative catching the tabs ;p

eric
 
Back
Top