55 Replies
This CurrentTB property is the Current Text Box in the selected TabPage.
How can I create a TextChanged event handler for the CurrentTB property?
Winforms?
You can't set an eventhandler on a property and have it follow the property reference, so you'll need to add the eventhandler to ALL the textboxes and filter the event source in the handler itself
The CurrentTB property is the current selected text box in the selected tab page. Because I am making an HTML IDE with tabs and I need to make an event handler on the current selected text box.
Well, either have all of them be subscribed and filter, or manually register/unregister the events as the user changes tabs
those are your options
there is no silver bullet here
what do you mean by register/unregister?
you can subscribe to events with code, not just in the designer
and you can unsubscribe too
subscribe?
what is subscribing?
textBox.TextChanged += YourHandler;
that subscribes to the textchanged event on that box, with the method on the right being the handler that will get invoked
you can do -=
to remove the eventhandlerCould I put this code in the load handler?
Like
MyApp_Load
in theory, but will the tabs be created on load?
the tabs will be created by pressing a toolstrip button
so not at load then
the tabs, and the textboxes, must exist when you register. so I'd think you'll have to register when a tab is activated, if you want to go with that approach
alternatively just keep track of the current active tab (and its textbox) and check if the event is being emitted from the current active box
@Pobiega The event handler thing worked, but my IDE has a split view of a browser which displays your work, and a tabcontrol that controls the current text boxes and such, when I try to make it so that the browser displays the current text box's HTML when you change the tabpage, it gives me an error.
that means
CurrentTB
was nullthe text in the
CurrentTB
is null?that, or
webBrowser1
is
and no not the text
the CurrentTB
itselfI don't understand, when you press the button it should create a tab with a CurrentTB text box.
But this error shows when I try to create a new tab
use the debugger to figure out what is null
It is stating that "Object reference not set to an instance of an object"
yeah thats the text from "NullReferenceException"
that means an object refernce was null, when you used it as if it wasnt
stack overflow usually means you have an infinite recursive loop
ie, a method calling itself over and over
It is not showing me what is
null
$debug
Tutorial: Debug C# code - Visual Studio (Windows)
Learn features of the Visual Studio debugger and how to start the debugger, step through code, and inspect data in a C# application.
where do I go here to debug?
read the guide
use breakpoints
inspect values
@Pobiega How do you make it so that when all tabs are closed, it closes the form? Like in an if statement.
You can probably register an event handler on tab close event and count the number of tabs
I tried doing something like this but it closes the form when I close one tab. (Items are the tab pages)
thats... a very weird if statement
you're checking if the collection is not null
you want to check that the collection has 0 items
how can I check that?
Im sure you can figure that out without handholding
this damn pack that I am using is just hurting my brain lmao
I just don't understand why this won't work.
what exactly does
+=
do here, do you think?I have no clue to be honest.
I don't know why there has to be == or != or +=
what do they mean exactly?
they all do different things, suprisingly
==
is an equals comparison
it checks if two values are equal
!=
is the same, but checks for NOT equal
+=
is the increment operator, it increases the left value by the right value
ahhh I see
what would I put in there for this situation?
^
in the If statement
if (tsFiles.Items == 0)
?yay
you did it
well, almost
bummer
tsFiles.Items
isnt a numeric value
its a collectionoh
you need to check a certain property ON the collection
If I go to the collection there would be the items and such in the collection
sigh
tsFiles.Items.SOMETHING == 0
figure out what SOMETHING should be...oh oh
I am stupid as hell sometimes
yay
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.