|
[b]Hello everyone.[/b]
I am trying to create a basic project in vb.net. In this project i have a richtextbox with name editingarea and a button with name button1.
I just want that when the button1 is clicked a font selection dialog box will open where the user can select the font name and size. then set this font for rich text box.
But I am getting some kind of error as "Property name is read only", "Property size is read only", after setting the readonly property to false too.
Here is the code
If SelectFont.ShowDialog = Windows.Forms.DialogResult.OK Then
EditingArea.Font.Name = SelectFont.Font.Name
EditingArea.Font.Size = SelectFont.Font.Size
End If
Can someone help me out.
[b]Thanks[/b]
|
|
|
|
|
Some Properties of a Font cannot be changed after construction. But you can set the "whole" font:
EditingArea.Font = SelectFont.Font
|
|
|
|
|
I want to change all properties of fonts such as name, size, fore-color, back-color, bold, italic as the user wishes.
Can U tell me that how should I go. O can you provide me some code snippet for the same.
Thanks
|
|
|
|
|
Once a Font object is created you cannot change any part of it.
So, the only way to get around this is to create a new Font object and set the Font property of the RichTextBox.
Dim newFont As New Font(fontName, fontSize, fontStyle)
myRichTextBox.Font = newFont
|
|
|
|
|
Student10230 wrote: I want to change all properties of fonts
You're thinking like a user in terms of what you want. You can't set the individual properties of a font, you'll have to create a new object with the properties that you need;
richTextBox1.SelectionFont = new Font(richTextBox1.Font,
richTextBox1.SelectionFont.Style ^ FontStyle.Bold);
It might be working exactly as the user expects as you're not changing a property, but creating a new object with the correct properties. Same goes for the other properties; if they're readonly, you'll probably have to replace the entire object.
Bastard Programmer from Hell
|
|
|
|
|
Tsk Tsk! Posting C# in the VB.NET forum. Talking about dangling a carrot and pulling it away when they bite for it!
|
|
|
|
|
|
Just put "replace brackets and semi-colons by verbose keywords when appropriate" in your sig, and all will be fine.
|
|
|
|
|
Fix'd
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
|
Hello everyone, currently I am working on a project, in which I have save some text, and images on disk in encrypted format (means no other application except mine may be able to read). But I have never worked before on such project (means creating a new file extension for some special purpose, on data encryption). So I am bit confused about it.
So can U please help me in this respect, or point me towards some good tutorial which can help me.
Thanks
|
|
|
|
|
There is nothing special about creating files in your own format, all you need is to include some meta data or other pointers to show the type and length of each record. So for example your file type contains text and images you would do something like:
Create new binary stream file
Write header information
Do
Write text identifier record: flag 0, length L
Write L text characters
Repeat until all text is written
Do
Write image identifier record: flag 1, length M
Write M bytes of the image data
Repeat until all image data is written
Repeat as required for other content
Close file
When reading back you just use the identifier records to rebuild your text or image blocks in memory and display or otherwise process them as required.
|
|
|
|
|
Thanks for the suggestion man, but can elaborate your code some more. How to use binary stream.
|
|
|
|
|
Start here[^], also look at the StreamXxx classes. There is sample code in each section, none of which is very complicated, you just read and write Byte arrays to stream objects.
|
|
|
|
|
Thanks man, It should help me.
|
|
|
|
|
Alternatively, you could use a file-based database, like Sqlite.
Bastard Programmer from Hell
|
|
|
|
|
Create a folder, store all parts there in individual files. Then zip the folder, you may use a password for that. Change the extension to your own extension.
For opening the file, just reverse that process.
And do not forget to delete the folder after it was zipped, or after its contents were read.
|
|
|
|
|
Thanks for this method its great.
But can u suggest some better method for this purpose. Means actually creating and registering a new file format.
Thanks
|
|
|
|
|
Hello everyone, I am a complete beginner to vb.net. I want to create a basic application, which can open and create files like ms word (which can contain formatted text, images and videos too).
I am a little confused that how to create it, means which control i should use, in which the file will be created and viewed. I am currently thinking about RichTextBox.
Can U give me some better suggestion, that how to go through this application, i am just in beginning stage.
Also please give some suggestion that how the files will be created (which can contain text, image, video).
Thanks.
|
|
|
|
|
|
Hello,
making a word file while using a vb.net application inst really that easy (specially when you want to use more then just text).
for a control i would really know, a ritch textbox doenst support video, and im not to sure about images and outlining either.
for the code to get the stuff into a .doc(x) file and back i would recommend to read this[^] article. mind you that you need a office client installed to use that sort of code.
|
|
|
|
|
Actually, i have nothing to do with MS word (i mean just like MS word). I want to create a application which will provide a editing area to user, where one can create a formatted text file, add images, videos. Save them on disk and later re-open them when needed.
But i am confused that a how to start, which control to use and how to store them in fie.
I just need some suggestions that how to go through project, i need some basic ideas and tips,so that i can continue.
|
|
|
|
|
Not sure if its an idea, but what if you used a webbrowser control and make it so your application can write html code.
that way a user can create a file, your program writes a html file (and store the movies/images) witch it can read later on again. that way you don't have to worry about how you want to store the outlining of your file.
if you dont want to use HTML, then i don't really know how you might do this. I'm afraid you have to make your own control/look on the internet for a downloadable control to do it.
|
|
|
|
|
how to pass criteria in fillby
|
|
|
|
|
You might want to provide quite a bit more detail about what you're doing and what you're using. What object are you calling "Fillby" on??
|
|
|
|