Newbie question about frames...

  • Thread starter Thread starter Kevin
  • Start date Start date
K

Kevin

I just converted an existing VB6 program (small one) to .NET 2003. In
my program, I use a frame to hold a bunch of textboxes. When the
screen is loaded, the frame enabled property is set to false so the
user can't edit any of the data in the textboxes. The frame's caption
is greyed out since it's disabled, but the textboxes are not--the text
is still black and looks normal.
Now that I converted it to VB.NET, when the frame is greyed out, so
are the textboxes. I had masked edit controls in my VB6 program that
got converted over. They are the only controls in the frame that
don't get greyed out.
Is there a setting somewhere or a better way to do what I'm doing?
 
Hi Kevin,

I asume that with a frame you mean a panel or the groupbox

In VB.net a control is always the child of his parent.

So you have to look if the enabling and disabling of your textboxes on the
panel looks something like this
me.panel.textbox.enabled=false
while if they are not on a panel it looks like this
me.textbox.enabled=false

I hope that is what happens?

Cor
 
No suggestions? I'm guessing I'll end up using the 'Locked' property
instead. So I go from one line of code:
Frame1.Enabled = False

to 50 lines:
Textbox1.Locked = True
Textbox2.Locked = True
Checkbox1.Locked = True
Button1.Locked = True
etc.

And VB.NET is supposed to be easier? What's the replacement for VB6's
'app.path'?
 
Kevin,

I dont know .locked property

Can you explain something more.

That enable from a parent should be enough to enable all childs.

Maybe you can sent a piece of code where it happens.
I will try it also

Amd I think that app.path is application.startuppath but I do know very few
from VB6.

Cor
 
Yes, enabling the parent will enable the childs and the same with
disabling. The problem is I don't want to disable the textboxes with
the frame, at least not have them LOOK disabled.

The frame's enabled property set to False at design time. When the
user clicks on the 'Edit' button, the frame's enabled property is set
to true, giving the user access to change the text in the textboxes.
There's really nothing to see if I sent you the code...

The 'Locked' property in VB6 would allow the user to click on a
textbox, but not change any of the text in the textbox. The textbox
could also still 'receive focus'. I'm guessing the VB.NET 'Locked'
property works the same way.
 
Hi Kevin,
I understand now what you want I don't need the code.

Maybe is this what you are looking for, I did put it direct in code because
it is for new ones in VB.net mostly a crime to do this.
\\\
Dim ctr As Control
For Each ctr In Me.Panel1.Controls
If (TypeOf ctr Is TextBox) Then
DirectCast(ctr, TextBox).ReadOnly = True
End If
Next
///

I hope we are coming more near the goal?

Cor
 
Yes, I thought of doing this. There are about six buttons that need
to stay enabled, so I would have to add lines of code for them. So
one line of code now becomes ten lines of code, which brings me back
to the point that VB.NET was supposed to simplify things, but it's
not.

Thank you for your effort.
 
Back
Top