Slowly from everyone.
Welcome back to desktop application course.
And in today's class we are going to study about rich text boxes and text of applications and we'll
see tool tips as well.
Basically when we already we have seen all we have experience in dealing with not packed like applications.
We have seen notepad.
We have worked on notepad and we have seen similar applications like Notepad.
OK so what that text box is.
Which textbooks basically.
So if you wish to add that similar functionality inside your application desktop application so you
can use rich textbooks instead of normal textbooks.
And what are the tooltip are to live is basically a message or a pop up that appears when you will focus
is a particular control.
OK.
So we'll see both of these in this lecture number nine.
Let's start.
OK.
So I have created a new window with the name rich text box example.
And in this particular window I am taking a little textbooks here.
I have my rich textbooks look.
This is a huge text box and you can work in like a notepad.
OK.
So if I docket in a parent container look and when I run this application from here from programmers.
Yes.
Right now for this example which text box example.
OK save it.
Let me zoom in so my first start up a screen will be my rich textbooks
look.
So it is very similar to my notepad application.
OK.
It is very similar to my notepad application.
And you can then save this file to your hard drive.
You can save this file.
OK.
You can open this file again inside this rich textbooks.
So all these are the things that we can do in file handling as well.
OK.
So I'll introduce you in this lecture how to handle how to create a file.
OK.
How to save this file.
So let's see and work in IT
OK.
So first thing I wanted to do is let me open this window and let me talk it out or make it OK.
None.
We'll get this as marriage textbooks and right.
Let me take a label and give it a name and your text.
OK.
And then I'm creating some buttons one is for save then
another button.
But first of all I am taking this button as save.
OK.
Save and then open.
OK.
So these are my two buttons.
This is massive buttons.
Give it a name as save button.
And this is my open button.
So give it name as open button Ok open and button.
OK.
So what ever you wrote inside this rich textbooks should be saved to a file for.
For using file handling.
You have to come here inside your code and you have to import using System Dot.
Are your input output without this file you cannot be.
You are unable to open file handling controls and classes.
OK.
So first of all I'm checking a condition if my textbooks my name off my textbooks is this is my rich
textbooks.
Let me close other windows so that I can get my textbooks to design.
This is my list textbooks so name it as bad our text let me use paragraph text.
OK.
So if I write here about our text that text is not equal to empty.
That means you should have some text.
OK.
So if you're a paragraph text is not equal to empty.
Then do what file.
This is a class for using file handling file.
Dot write all text write or text.
What does this method do.
This method creates a new file.
OK.
This method creates a new file and write a specified string to the file you think is specified encoding
and then it closes the file in the target file already exists then it will be overridden if the target
file already exists then it will be overridden.
So you have to mention the file name and you have to if the file already exists then you can this file
will be that file will be audited.
OK.
So write or text right or lines look.
Right.
A new file create a new file by using a specified encoding with a with the collected data collection
of the strings to the file and then closes the file.
Right all right.
If you have bytes if you have a bite at it.
OK.
So said creation times at loss X this time read all text read lines replace.
You have many options in the file class so that you can use you look open read Open Text open move you
can do whatever you wish to do with your file you can delete your file you can encrypt and decrypt your
file and you can create or you can do anything copy append text if you wish to add existing text to
your New You.
It's very new text to your existing file.
You can use all these functions so right now I am creating what I am creating right.
All text I'm doing this one right all text it is asking me the part of my file where should I save my
file.
So I giving a part to my documents window so for documents window.
Let me take apart from this string s all you can write apart equal to environment.
We have another class environment that get special folder.
Get folder part and open this bracket and it is asking me to give my special folder.
So environment our special folder docked my documents.
OK.
So this is the way to go through your mind documents but every P.C. had a by default my documents folder
so you can access that my documents folder by using the environment class and then using the get folder
path method and it is accepting environment our special folder so that you can access my documents all
your Downloads folder or your pictures folder or videos for the next day.
Is that clear.
OK.
So this is all you can get your My Documents.
But then you reach to your My Documents.
But inside that part you are trying to save your file so you you will give the a name you will give
a name to your file.
Okay.
So how can you take the name you can take the name from here from your text box.
Okay Lexi I'm taking a text box here.
Text box and here you are specifying that Please enter your file link.
Okay let me make it a little bit down.
Okay now copy this label and paste it here and save now file limb by limb by limb and this is file Lim
text
file name text.
Okay now what.
Come in your save button.
If this bed is not empty and and file name text dark text is not equal to empty.
I hope it is cleared now.
So if both the file name and this the better text are not blank then this code will be executed.
So when I wanted to save my file here in the path that I have taken of my documents inside this path
document I am entering file.
That is my file name text or text so why I have use this thing.
I used this thing because I have used this thing because let me show you the path look.
So you leave your documents.
Okay.
When you click here look and when you apply a backslash you'll get all the files so you are creating
your file you are saving your file inside your documents.
So this is your documents by then when I applied backslash buttons encoding.
You have to apply a double backslash so that it can be understood by a C sharp combined.
That is the single backslash whenever if you wish to apply a backslash you can not enter a single backslash
you have to enter double backslash for part okay or you have to add editor symbol before you but otherwise
it will not entertain you.
Okay now the next thing is the content.
Where is my content my content is in that text.
Don't text.
So I have given my content.
After doing this write a message what it is returning it is returning nothing.
So write a message.
White sorry.
Message box.
Message box door to file created
successfully.
Okay.
So Alexis started this program and checked what will happen.
This is my application.
Let me zoom it.
I'm entering some text.
Hi.
Hope you are enjoying.
OK.
Hope you are enjoying.
I have skipped the space after this message.
I have to give my file name and my filing will be welcome.
Got the expertise.
And when I press the save button is saying we file created successfully.
And after creating this file let us stick.
Is that is it.
Is that file created or not.
Yes I have created this file on my harddrive double click on it.
Look.
So this is how you can create a notepad like application in C sharp.
OK moving forward.
Let's check some more options.
What if I wanted to.
What will happen if I add a new texture new content.
OK if I'm writing new content here and then saving the blessing to save.
But then again then the file created successfully again.
The method has been shown on the screen but this time this time what will happen.
My this welcome file will be replaced with my new file the previous file has been replaced with my new
file the text with the text will not be appended because I don't text method creates new file every
time and replace the existing file so you can avoid this thing by using some different methods.
How.
Let us see now I am adding one more condition inside my C sharp code that if file not exists.
This is my class and this is a method that exists file not exist.
If my file exists this is a boolean method that means it will return true or false.
Okay so file not exist will I should enter my path.
So this bot should come before this if else so that I can get my bot and can idea bot concatenation
and you have to enter the file name when you you have already.
When you press the button the file name should also be there.
OK so same file lame file name text not text.
If this file exists OK in this but then what to do.
You can show a message which message lacks a message box starts to file
already exists.
OK.
File already exist.
Else
as do this in the file already exist.
It will not carry it will not right.
OK now a file already exists then what to do file.
But you can ask the user at runtime that do you want to add or replace or do you do you want to open
the new content into your existing file.
Then what will you do.
So let me take a new class that is.
This is a property basically and it belongs to some class of dialog reserved dialog result.
The what this class will do this class will get the response off your message box.
You might have seen when your message box appears on the screen.
The key button is coming by default in the message box.
Okay.
But I wanted to display yes and no inside my message box.
Do you want to open your file or no.
Yes or no.
So I wanted to get that yes and no and place are stored inside a container and that is my container
that is accepting my message box reserved.
OK so how can I show yes no buttons message boards don't show has some more properties and that I mean
just as well.
The first thing I have to give you the message that means question file already exist.
Then the heading of the message and then message box buttons dot.
Yes.
No look you have many buttons.
Okay cancel retract cancel yes no cancel.
So yes no.
And then what it is leaving a message box I message box.
I can talk to cushion if you wanted to apply I can only your message box so these all out of my icons
so push in because I am asking a question and what is my question.
File already exist.
Do you want to add current data to this file.
Okay and question mark.
So when you press yes or when you press no the result will be stored in this data.
OK now you can check if the R is equal to equal to dialog result.
That's the property that yes if yes has been the.
That is all that is stored in the art.
Then what you can do you can do file for the file but append all lines append or text and append text.
OK so I am taking this append all text and it is asking me the same thing append means to add to join
to do to concatenate your existing or your new text with your existing text OK or your new string with
your existing string so append or text what it is asking me without asking me the part.
So part is my this one and the file name is file name text dot text.
This is my complete path off my file and the contents will be better.
Text don't text.
OK so what would have been let's have a look again if my book text books are not empty.
Then it will come in and then I'll get the part of my documents folder from this particular line of
code and then I have checked that is the file exists.
If the file exists then this message box will be appeared on the screen and it ask you whether to continue
appending the text or not.
When you press yes then this is really validated and you'll append your text inside your existing text
in the file.
But what if if you press no.
If you press no then something should happen.
Nothing should happen.
OK.
Actually nothing should happen then let's stick it.
What will happen.
Start let me write something.
Today is redness day OK.
Today is Wednesday and the filing is what was my filing there.
Welcome back to the 60s.
So can I right here.
Welcome.
Good to see you again.
Welcome dot the 60s and then save it is seeing me that file is created successfully right.
Let me check.
Let me forget why it is not running.
Put a brake point here inside your code and then save it again and come inside.
Yes we have text in this.
We have text in this welcome text that I've got the part I've got the whole documents but then find
it exists but plus file welcome Dirty Sexy.
I have done a mistake.
That's the mistake.
The mistake is this one.
That's the mistake.
I haven't applied the backlash for accepting my fight.
Now if I take this look file exists.
Okay.
When I come next I am pressing F eleven key to move forward.
Now it is doing me that I logbooks look file already exists.
Do you want to append current data to this file.
Yes.
Okay.
If I press yes then I'm coming.
And then the text will be appended to my new file.
Let's check go through your documents.
Double click on it.
Days because in the previous example I have created again the new file.
So let me add once more save and step out step out.
Yes I wanted to append and see what will happen.
Still it is not appending it is not appending y.
Let me check.
Okay so the problem is here also we have to say double backslash.
OK.
After that after my documents but look double back let's keep it updating after each directory see.
Then double backslash users and double backslash and then only then documents.
So after documents I have skipped this double backslash for my file.
So I have applied this double backslash here and now I'll check what will happen append IFRS def 11
key so to move forward.
Now what will happen next.
Close this file and come here Open this file look the new data has been up and it will file.
You can apply a line break speech breaks and you can do everything whatever you can do in your notepad.
So this is all you can use the rich textbooks.
This is the example of your rich textbooks.
So I am not going to cover all the expense of a notepad right now.
OK so now let's go to our next topic that is are toolbar tooltip.
How can I apply tooltip inside this this text box.
Let us select tooltip.
Where is my tooltip.
Here is my tooltip drag and drop it here tooltip has no physical appearance on your screen.
OK.
In fact it shows in the bottom of your visual studio.
So when you select you or you apply a tooltip inside your application its properties are these OK so
tooltip will appear or it will stay for almost half seconds and popup delay order probably is almost
five seconds and then these are the properties the four color the back color the initial delay is balloon
tooltip visual delay.
So these are the timings that you can configure with your tooltip by default I am not changing anything
on this show.
The tooltip will appear anytime if you will if you select this particular property to do then you're
to issuing any every name.
Okay.
And then tooltip I can tooltip title to use animation use fading.
So all these are properties of your tooltip.
Let me show you.
I can hear in full.
Let's see.
Message data is in full and the icon is let's say in full.
And that's it.
Right now we leave it to these two properties.
And now when you come here on your filing that Paul give should appear so select your file name text
box come bottom and look for tooltip look you'll see this particular tooltip on every control.
Once you have applied a tooltip inside your application so select your tooltip tooltip on tooltip one
determine the tooltip shown whether when the mouse who was under control.
OK so presenter to begin a new line give you a message.
What what do you wanted to display please.
And
file name with extension.
OK so that no one can get a mistake without file extension.
OK.
So let's check this whether the tooltip appears or not.
So when our focus is here look this is my tooltip.
If I if I zoom in.
This is my tooltip and I've come out are going to come in again.
Look.
So you can increase the appearance of your tooltip with respect to seconds and degrees as well.
Let me show select your tooltip again.
Look all they show.
Where was that all this show.
This one double click.
Stuck on racial
so it will any time you come here on your textbooks look it is showing again and again in a more faster
manner you can increase delay you can make it's delayed to zero let's say there is no delay next week
then you come up it is coming
look and if you remove this delay to two thousand or two possibly to two thousand two thousand means
two seconds you have to enter time in milliseconds and your windows C sharp.
So let's stick
OK so that's all for today.
Hope you have understood how can you apply to.
And how can you use this textbooks.
One more thing I can show you.
Let us select this rich textbooks.
Then you go downwards.
Look you have to live here as well.
You have only select one tooltip.
But let me add some text into Zurich textbooks and your paragraph lets you enter your paragraph.
OK.
Save stuck
look and come when you come into it all displaying the different tooltip.
So you have selected only one tooltip or on your application.
But this to live works differently on different controls based on the different message you have provided.
OK so this is all you can guide your user or your application customer whatever you have you can do
them and guide him with respect to an application what to do with this control or how to do with this
control.
OK.
So hope you have understood everything.
Thank you so much.
Text.