B4J Question Control Id

Daestrum

Expert
Licensed User
Longtime User
Where in the internal designer can I set the Id for the control ?
 
Hello @Daestrum

I think you might be referring to the 'Name' property in the section 'Main'. This is where I set the ID of the controls that I use in code. If it's the same thing that you're after then don't forget to add Generate Members from the Tools menu. Before you do, make sure that you have selected the code module in the IDE where you want the references added.
 
Upvote 0
Thanks for the reply, but it's the Id I need not the name. At present ???.Id will always return null for any control.
 
Upvote 0
Ok, thanks Erel, will need to find another way to set the Id. All controls have an Id but not all have Tags :(
 
Upvote 0
Sorry maybe my previous reply was misleading, I need the id field for things like MenuItem which do not have a tag (according to the api they don't even inherit one).
It's not a massive problem as I can run through the scene and add the Id based on the name.
Ty for the reply
 
Upvote 0
I assume that the 'tag' field is the userdata field is that correct ?
The reason I asked about the Id is, without using the Id and using an external css file, how do you style a single control ?
 
Last edited:
Upvote 0
I assume that the 'tag' field is the userdata field is that correct ?
Yes.

The reason I asked about the Id is, without using the Id and using an external css file, how do you style a single control ?
Simple changes can be done in the designer directly or with the Extra CSS property.

If you need to set an id then you can do it in your code. You can also do something like:
Code: Copy
For Each n As Node In MainForm.RootPane.GetAllViewsRecursive
     n.Id = n.Tag
 Next
 
Upvote 0
Thank you, gets me closer to what I am trying to achieve.
 
Upvote 0
Back
Top