|
Hello Everyone,
I am using a RichTextBox to display text and graphics. I know how to load a previously created rtf file(rtb1.LoadFile(FileName, RichTextBoxStreamType.RichText)), but how do I create the rtf file. I using the RichTextBox for read-only purposes. I don't want the user to add or change anything in the RichTextBox. I am not sure how to print and add pictures to a RTF file. If I was creating a text file I would use the "Printline" command. Also, I want to use special formatting like Bold and different font sizes when I create my RTF file. Any Ideas?
|
|
|
|
|
|
OK, fistly I don't know how to attach files here, if at all possible.
To Save RTF Files, you could try :
RichTextBox1.SaveFile(sfMW.FileName, RichTextBoxStreamType.RichText)
For Bold, Italic and Underline, here's a Nice Sub you could use :
Private Sub ToggleStyle(ByVal style As FontStyle) 'style option1
Me.rtbMW.SelectionFont = New Font(rtbMW.SelectionFont, rtbMW.SelectionFont.Style Xor style)
End Sub
Then, you could just call it like :
ToggleStyle(FontStyle.Underline) 'underline
ToggleStyle(FontStyle.Bold) 'Bold
ToggleStyle(FontStyle.Italic) "Italic
The benefit here, is that the selected Font will remain the same when Formatting is applied.
For alignment :
RichTexBox1.SelectionAlignment = HorizontalAlignment.Left
RichTexBox1.SelectionAlignment = HorizontalAlignment.Center
RichTexBox1.SelectionAlignment = HorizontalAlignment.Right
Hope it helps!
H T G
|
|
|
|
|
How do I go about adding several lines of text to the RichTextBox? I can use rtb.text = "Text in a richtextbox" or I can use rtb.appendtext("This text is appended to the original text"). I have been using the Print and Printline statements for plain text files but for a RichTextBox what should I use?
Thanks for all of your help.
|
|
|
|
|
I'm using a table in the report design to display child records on a report. The data table the report table is using has many records in it, however, I only want the report table to display certain records from this data table. How can I go about doing this?
Thanks for any help on this matter.
|
|
|
|
|
hi,
have you tried using a dataview?
you can create a dataview and link that to the datatable.
set the rowfilter property of the dataview.
example<br />
dim DV as new dataview<br />
DV.table = MyTable<br />
DV.rowfilter = " field1 = 'something'"
you can assigne simple criteria to the rowfilter property.
then you can set the reports datasource to the view
MyReport.setdatasource(DV)
hence the new report source will have a filtered set of record.
U Xux
|
|
|
|
|
No I have not. I'm using the reportviewer control. My report has 2 datasources. Would adding a third one work? Also in the Init of the form with the reportviewer control I tried using the bindingsource.filter but it does not seem to work.
All I want to do on my report is list the persons name along with all of the detail records that are related to that name. Thanks for any help you can provide.
|
|
|
|
|
i am writing a webserver. i am using a winsock replacement control, that is API driven. It is called CSocketMaster , a version of the CSocket class.
any who, i need to pass a connection from the main process to a second process..
The second process starts, and in the command line i put the RequestID and i do SckMain.Accept RequestID but it dosent work because (i am assuming) its a diffrent process...
I need to know how i would accept a request from a diffrent process?
any help would be appreciated!
Visual Basic 6.0
-- modified at 13:44 Thursday 27th July, 2006
|
|
|
|
|
I have an application that will find a program based on processid.
I can then get the
Main Window Title,
Main Module Name,
Handle
BUT
I need to figure out how to then get information from that program's controls.
I am also having a hard time figuring out how to get the above information from the application's child windows. (Enum, I know, but a good starting point anyone?)
Vb.net 2003
Thanks in advance for any pointers.
|
|
|
|
|
Have you tried using remoting?
|
|
|
|
|
What is the code for connecting my windows application to sql server.
|
|
|
|
|
'set your connectionstring property of connection object.
'*************** Connection String *******************
' user id=@username;data source="@servername";initial 'catalog=@database"
'where,
'@username=your user name
'@servername=your server name
'@database= your database name
'*************** Connection String *******************
Dim conn As New SqlClient.SqlConnection("ConnectionString")
conn.Open()
!alien!
|
|
|
|
|
i want to calculate the size of all the files present in a folder how vcan i do this thank u in advance
|
|
|
|
|
Get a list of all the files, loop over each file and get its size. As you loop you accumulate the size in a variable. At the end of the loop your variable will contain the total size of all files in the directory you were looping over.
|
|
|
|
|
To simplify the steps, I have created two functions you can use.
1. The first function will get all files in specified directory. You will need to add them all up to get a total folder size.
2. The second function will convert from bytes to kilobytes.
* Note: I am not sure if you are using vb.net or asp.net. I used Vb.Net so you will see a message box in my first function
Enjoy!
'Get File sizes in directory
Public Shared Sub GetFilesSizesInDirectory(ByVal Dir As String)
'Declare a variable to recieve file name
Dim FileName As String
'Iterate through specified directory
For Each FileName In Directory.GetFiles(Dir)
'Get file info and out file size
Dim Info As FileInfo = New FileInfo(FileName)
MsgBox(FileName & " " & ToKilobytes(Info.Length) & " KB")
Next
End Sub
'Convert from bytes to kilobytes
Public Shared Function ToKilobytes(ByVal Key As Long) As Long
'Variable to recieve remainder
Dim Remainder As Long
'Result of calculation
Dim Result As Integer = Math.DivRem(Key, 1024, Remainder)
'If there is a remainder always round-up
If Remainder <> 0 Then
Result += 1
End If
Return Result
End Function
Tyquaun
-- modified at 22:53 Thursday 27th July, 2006
|
|
|
|
|
Tyquaun Hunter wrote: Note: I am not sure if you are using vb.net or asp.net
What is he's using VB.NET and ASP.NET?
VB.NET is a language. ASP.NET is a framework for writing web applications. The two are not mutually exclusive.
I think what you meant to say is: I'm not sure if you're using a Windows Forms application or a Web Forms application....
Actually, that's not really correct either, because what if it is a console application, or a windows service.... Never mind. It's Three in the Morning and it is too hot to sleep.
|
|
|
|
|
Actually, you are right. However, what I have noticed is when people say VB.net they mean winforms and asp.net, well it is assumed I am talking about ASP.net/VB.net because I am in a VB.net forum.
-- modified at 22:44 Thursday 27th July, 2006
|
|
|
|
|
i am using only Visual Basic.thank u for the solution
|
|
|
|
|
Hi,
We already have a windows service set up to write to binary file for "our" custom events. Need to translate this binary file into comma delimited text file - how would we go about doing that? Can we just some built in VS2005 functions?
any ideas/thoughts much appreciated.
Thank you for your time.
|
|
|
|
|
Se the post a few lines down entitled:
" Converting from a byte array to a string?"
|
|
|
|
|
Please don't cross post.
---
b { font-weight: normal; }
|
|
|
|
|
Im looking for the code to copy a complete folder with its entire contens to a target folder. I'm looking for this quite a while but i was unable to find it. Can anyone help me?
Thanks, Zaegra
--Zaegra--
|
|
|
|
|
Try this. It is a two step process.
1. Create your destination directory with the same name as your source directory.
2. Get all of the files in your source directory and copy it over to your newly created destination directory.
* Note: You should prompt the user that destination directory already exists and if it does, give them an option to overwrite it. If not, it will overwrite automatically. Also, you should prompt the user that the file exist that you are about to overwrite. I just bypass existing files. You might have to perform some other types of error handling, but fundamentally, everything you need is there.
Good Luck
Public Shared Sub CopyEntireDirectory(ByVal SourceDir As String, ByVal DestinationDir As String)
'Create Directory
Directory.CreateDirectory(DestinationDir)
'Declare a variable to recieve file name
Dim FileName As String
'Iterate through source directory
For Each FileName In Directory.GetFiles(SourceDir)
'Copy file with each iteration as long as the file does not exist
If File.Exists(DestinationDir & GetFileName(FileName)) = False Then
File.Copy(FileName, DestinationDir & GetFileName(FileName))
End If
Next
End Sub
Tyquaun
-- modified at 22:54 Thursday 27th July, 2006
|
|
|
|
|
Now hope it works, thanks!
--Zaegra--
|
|
|
|
|
Oh yes, one more question: does this copy the sub-folder in a directory to?? Should i try doing that with your code and by getting the names of each sub-folder? Thanks again, Zaegra
--Zaegra--
|
|
|
|