Placeholder property seems to be missing from textbox?
Could someone please inform about any possible reasons as to why this property is missing?
99 Replies
I am trying to make a search bar for my Winform app, and I want a placeholder for my search bar so that it is clear to the user what they are interacting with, but the property of the textbox seems to be missing.
It's called
PlaceholderText
IIRCI have sorted the properties alphabetically, and it is only displaying PasswordChar
This is what I can see
I wonder if you need to set it with code, for some reason
Have you ever had this issue before, or had to do something similar?
I never used Winforms
Well, sorry, once in college I made a shitty calculator with it
Ah, I see
Do you know of any packages that I can install to add more items to my toolbox?
Perhaps I can download a toolbox add on?
Does that exist?
There are nugets with additional Winforms controls, yes
$winforms
Uh, wrong tag
Sec
Bruh, I swear it's not even that advanced of a project
Just a symbol/character library
Still, definitely more complicated than anythin i've ever done before
Also, what is MODiX?
It's the bot running on the server
And, you are correct, it's not that advanced
Not sure why you're asking for 3rd party controls
There's no $winformsuilibs tag, alas
I am struggling to make it work
Does the placeholder property not work from code?
I don't know how to use that
Ah
Well, might I suggest looking for some Winforms tutorial, then?
You should have a
.cs
file with the code behind the form
There, in the constructor probably, you might be able to set whatever properties of any controlI have Form1.cs, and Form1.Designer.cs
I have been using Form1.cs, but I still don't know how to reference a specific object
Like a textbox
For the datatables, I just instantiated them in the Form1.cs, and then stacked them on top of eachother to simulate drop down menus, before then linking those to datagridview tables, which are what display my characters
Could you recommend something? I have looked at some before, but they never proved to be very useful to my project
Create a Windows Forms app with C# - Visual Studio (Windows)
Create a Windows Forms app in Visual Studio with C#, add button controls to the form, and run the code to test your application.
Microsoft documentation is always a good place to start
In fact, I was following a winform tutorial before creating this thread asking about the placeholder property, which doesn't seem to exist on my property list
Thank you
I am still confused as to why that place holder is missing though
¯\_(ツ)_/¯
Could be you're using an older version of .NET that doesn't have it, could be it's not exposed to the designer, idk
What do you mean by being exposed to the designer?
It's there in the code but not here
In the designer code?
In the TextBox code
The TextBox is a class, defined with code
Here is some of what I have in my designer
That class might have a property
PlaceholderText
This is not the designer, this is the code behind
Just so we're clearThis is what I see
It seems
this.searchBar
is your search bar
Try the .CodeBehind
property on itIs the designer the page where I can drag and drop things onto the app?
This is the designer, yes
Ah ok
Ah, well that's the textbox that I dragged in and labelled searchBar
But it currently does not do anything
What does this do?
Uh
It's... a property
Let me guess, you don't know C#?
As I said, I am a beginner
Quite inexperienced
I'd certainly recommend starting with anything that's not a UI application
Well, this work is due soon, and I can't really afford to restart
Although I would agree with you, this probably was not the best thing for me to choose
Although my options were limited
To answer your question, then, properties are public accessor to the inner state of a class instance
I had to us a database for my project, but it was either this, or use a website and use SQLite
A website would've been easier tbh
I think I understand, but would you mind elaborating off of this?
Perhaps, although some of my friends have been having a rough time as well
Angius
REPL Result: Success
Console Output
Compile: 493.486ms | Execution: 43.467ms | React with ❌ to remove this embed.
OOP?
Yes
C# is an object-oriented language
Damn, I had a really good OOP program that I made a while ago
But when I sent my laptop in for repair, I didn't save it on a USB, so lost it
By accident of course
And now I can't remember how that stuff works
Use Github in future
Free backup and versioning with Git
I always have syncing issues
What is is called when your variable tb references mycooltextbox?
I have used that to make datatables?
Also, can you make a new object by using var?
tb
holds a reference to that instance of MyCoolTextbox
var
is for type inferenceI thought var was for variable declaration
It's the "figure out what type this is" type
are all eqivalent declarations
They all do the exact same thing
I see
What do you mean by saying it holds a reference?
Do you mean that it carries the same attributes as the parent class?
And that tb is the child subclass?
The instance is stored on the 1782th shelf
tb
holds shelf:1782
A reference to where the instance of that class is in memory
Not the instance itself
Nor a copy of that instanceCould you please expand your explanation?
And also, what is the relevance of shelf:1782?
A computer memory is a set of boxes
Each box has a number
Yes I know this
The instance of the class is placed in one of those boxes
You are talking about address locations in memory
The variable stores the number of that box
Got it
Wait hold up
I thought that the box stores the variable?
That's why we can do
Angius
REPL Result: Success
Result: int
Compile: 321.592ms | Execution: 34.129ms | React with ❌ to remove this embed.
a
, b
, c
, and d
all store a reference to the same boxI am confused with the output of this program
If b references a, c references b, and d references c, then why are a and d different?
They do not reference each other
They store the same reference
The value of
a
is, say, box18
Then, we assign that value to variable b
, now it also holds box18
And so on
References themselves are not passed by reference, if that makes senseIndirect addressing?
The number of the box is not stored in a box
Direct
a
, b
, c
, and d
store the exact same reference to the exact same place in memory???
Ok, so why is a.Bar = 69, and d.bar = 420, but then a.Bar outputs 420?
Because
d
stores the same reference
So we go to box 18
Take what's inside
And change it's Bar
Ok, so does .Bar change what is inside of the memory box?
Yes
That's how all classes work
Why did you call it Bar?
No reason
Could be whatever
Ok
So you were running that function relative to the variable a?
Angius
REPL Result: Success
Result: int
Compile: 331.821ms | Execution: 33.981ms | React with ❌ to remove this embed.
Thus taking up space complexity of 2 for that function?
Similar to how a merge sort works, except it just creates 2 copies?
There are no copies
Ok I have another question
There's only one instance of
Foo
What is the difference between a class and a function
Fundamentally
I know that they are very different
But what are their different use cases
?
Being used on a.Xyzzyx and d.Xyzzyx?
Both
a
and d
reference the same box, with the same instanceOh
Oh
Oh
Damnit
Yes
I am being a fool
And so do b and c?
Also, what is the point of using the getter and setter?
When there isn't a getter or setter written into the code?
The getter and setter still runs
It's just syntactic sugar over getter and setter functions from lesser languages
That
a.Bar = 1
runs the set
ter
And a.Bar
runs the get
ter
$getsetdevolvecan be shortened to
can be shortened to
can be shortened to
can be shortened to
A function (or a method as we call them in C#) is something an object can do, a class describes what that object is
I see
That makes sense
But what is the point of making bar go to _bar?
In this particular example? No point
But you have some logic in the setter
So until we get the
field
keyword, you will need a backing field
That way the property doesn't have to reference itselfWhat do you mean by the field keyword? And why would the property references itself?
Ah, sorry, I got this thread mixed up with another one
Nevermind what I said lol
But, yeah, in the case above there's no point having a backing field
But if you want to have some logic, it's a must
Ok, but why?
Is it to do with private and public variable types?
This, you cannot do without a
_name
field
This would cause an endless loopBecause you would change the original value, which is not what you want to do?
Getting from the property would call the getter, which would attempt to get from the property which would call the getter, and so on ad infinitum
How come?
Oh
Ok
That makes sense
Hence why you need to make a new variable
Basically, a
And assign it the same value
Infinite recursion
Yes
Thank you for the help you have given me
Anytime