|
hi priya, you want to open notepad means notepad exe or a notpad file(i.c .txt) in a ritch text box using vb.net... if you explin this to mw i can try
regards
sumedha
|
|
|
|
|
hi sumedha,
i want to open an existing txt and should be able to edit and save the same file at a stretch.for this should i use savedialog or openfiledialog suggestions pls.
thank u for ur great effort sumedha
regards
priya
|
|
|
|
|
The OpenFileDialog doesn't actually launch anything. All it does is let the use pick a file which is returned to your application as a String,
C:\Documents and Settings\username\myFile.txt
It's up to your code to do whatever you need to with this String. In your case, you have to launch Notepad, so you use the Process class to do this:
openFileDialog1.Multiselect = False
If openFileDialog1.ShowDialog() = DialogResult.OK Then
Dim myFilePath As String = openFileDialog1.FileName
Process.Start("Notepad.exe", myFilePath)
End If
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hi priya ,
i have one code for you ..... just go through it .. this is very simple code created especially for you ....take one open file dialog box, one button on form and one ritchtext box on the same form.... now here is the code...
on button click....
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
OpenFileDialog1.Filter = "Text files (*.txt)|*.txt"
OpenFileDialog1.ShowDialog()
End Sub
and on file ok event of openfiledialog box
Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
RichTextBox1.LoadFil(OpenFileDialog1.FileName,RichTextBoxStreamType.PlainText)
End Sub
thats it its will opwn the file on the ritcch text box...
using this RTB you can edit the file
and using save dialog box u can save it
i hope this will help you.....
bye
regards
sumedha
|
|
|
|
|
I'm using THE api(SendMessage or PostMessage) to send a custom message between 2 VB.Net exe's. The called exe is subclassed to listen to the custom message. In the calling exe, I'm trying to pass a string in the 4th parameter. At this stage the 2nd exe is already running. The api call keeps crashing the 2nd exe. Can it be done across exe's or only within the same exe, thanks.
thanks for your apply or provide sample code( the best :laugh )
you are welcome to visit my blog
|
|
|
|
|
I can do it now
I can use FindWindow,GetWindow and SendMessage to send message to a notepad app,just like this:
hWnd1 = FindWindow(null, "Untitled - Notepad");
hWnd2 = GetWindow(hWnd1, GW_CHILD);
sText =this.textBox1.Text;
SendMessage (hWnd2, WM_SETTEXT,sText.Length, sText);
but I don't know how to excute a word app's dictate by another app,help me please ,thank you!
you are welcome to visit my blog
|
|
|
|
|
You've managed to ask a completely different question from your original post.
This technique won't work on Word the way you want. It'll set the titlebar text of the document window, not the text of the document.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I have a dynamically created RichTextBox that is created in the forms "OnLoad" event. For some reason it will not set the focus of the cursor inside the Text area. Once the program is running and I use the same code again it creates a new one and automatically sets the cursor inside it. What is wrong?
Dim rtbTextArea As New RichTextBox<br />
Dim newTab As New TabPage<br />
Dim newTime As Date = Now.ToString 'Set newtime to system time and date<br />
Dim strNewTime As String = newTime 'convert newTime to string<br />
<br />
TabControl1.TabPages.Add(newTab) 'Add new Tab Page to tab control<br />
TabControl1.SelectedTab = newTab<br />
With newTab<br />
.Text = strNewTime 'Set Tab Page text to System date and Time<br />
.Controls.Add(rtbTextArea) 'Add the rich text Box to the new tab control<br />
With rtbTextArea<br />
.Dock = DockStyle.Fill 'Set Rich Text box area to fill tab page<br />
.ContextMenuStrip = ContextMenuStrip1<br />
.AcceptsTab = True<br />
.Focus()<br />
End With<br />
AddHandler rtbTextArea.SelectionChanged, AddressOf SelFontChk 'Assign SelctionChange Event Handler<br />
End With
Thanks in advance
Thanks,
Taen Karth
|
|
|
|
|
You can't SetFocus to a control until the form is displayed (i.e. active). If you want the control to have the focus when the form is initially displayed, set the control's TabIndex property to 0 (zero).
...Steve
|
|
|
|
|
it's easy to save the object in the registry as string...
but how to convert that string (after getting it from the REG) to an object telling the converter: "this is the context of this object type".
i tried using the typeDescriptor, but no help.
who can help! i need and excutable example (VB.NET code) using the Color Object!!
militiaware
|
|
|
|
|
I would suggest that you save the color in the ARGB for which is a 32 bit value. You can obtain this from the Color object by the Color.ToArgb method. You can then save this integer in the registry, read it back later and convert it back to a color object using the Color.FromArgb method.
|
|
|
|
|
I'm trying to write an XLS file from within a asp page. Have it working but can't find how to format Cells. Can do color and font but can't find how to do date and time formats.
objexcel.Range("A1:J2").Select
objexcel.Selection.Font.Bold=TRUE
objexcel.Selection.Interior.ColorIndex=41
objexcel.Selection.Interior.Pattern=1 'xlSolid
objexcel.Selection.Font.ColorIndex=2
All this works but been all over MSDN and google but can'find how to set cell properties so date and times are formatted correctly.
|
|
|
|
|
I want to create a VB.net script that will save a web site to a file. How can i do this? I actually will want to save several pages. This would be a weekly job. I know how to create jobs in job scheduler.
I don't know how to do the VB.
I know one way would be to use httpwebrequest and response but not sure how.
The Vb would direct my IE browser to a site then in IE it would save the file to a particular folder as "HTM web file only". (The default file save is a "web page complete" I don't want that) Then I need to dynamically name the file, otherwise they will all be named the same thing.
I was thinking maybe there is a way to create some sort of macro even?
Help is greatly appreciated
|
|
|
|
|
I am stuck with context menus and seem to be spinning my wheels.
I want to build a context menu in code, then perform actions based on the item selected.
I could do something like
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ContextMenu1 = New System.Windows.Forms.ContextMenu
Dim MenuItem1 = New System.Windows.Forms.MenuItem
Dim MenuItem2 = New System.Windows.Forms.MenuItem
ContextMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {MenuItem1, MenuItem2})
MenuItem1.Index = 0
MenuItem1.Text = "MenuText1"
MenuItem2.Index = 1
MenuItem2.Text = "MenuText2"
Button1.ContextMenu = ContextMenu1
End Sub
I would prefer to read each of the menu items ("MenuText1" and "MenuText2")from a config file as they change quite a bit and I would prefer to not hard code them.
To handle the click, I would need something like this:
Private Sub MenuItemSelected_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles menuitem1.click, MenuItem2.click
' code to handle event goes here...
' prefer to figure out the index of the item clicked and process accordingly
End Sub
The problem is that the compiler does not know the MenuItem1.Click or MenuItem2.click events.
Someone suggested a way to do this in C earlier, it looks like it would work in C but I am not sure how to implement in VB.
Any help is appreciated
|
|
|
|
|
Part of the solution is to define the menu item objects WithEvents thus:
Dim WithEvents MenuItem1 As New System.Windows.Forms.MenuItem
Dim WithEvents MenuItem2 As New System.Windows.Forms.MenuItem
Dim WithEvents MenuItem3 ... etc.
You'll then be able to trap the MenuItemx_Click() events.
A couple of drawbacks though: you cannot define local objects WithEvents, nor can WithEvents be associated with arrays so you'll need to define a bunch of menu item objects with global scope within your class to cater for the maximum number of expected menu items in your config file.
I have had no reason to do dynamic context menus so I'd also be interested in other people's solutions.
...Steve
-- modified at 19:38 Tuesday 13th September, 2005
|
|
|
|
|
By looking at the code it looks like that you defined menuitem* inside the sub Form_load and therefore they are "local" objects. The compiler correctly don't know them (they exist only inside the form_load).
Try to declare them as "global" to the class (adding the withevents clause as stated in the other reply) and then it should be ok.
|
|
|
|
|
I just purchased SQL Server 2000 Developer Edition yesterday from Amazon, and i'm disapointed. when i finally got it up an running, i went to the server explorer in my VB.NET Standard, and when i tried to connect to a database, it said:
"Unable to connect to database.
It is only possible to connect to SQL Server Desktop Engine databases and Microsoft Access databases with this version of Visual Studio."
wtf is up with that? do i need Visual Studio Professional? Enterprise? or do i really have to spend the $2500 on Enterprise Architect? i thought the $50 price tag on SQL Server 2000 Developer Edition meant it was intended for low-budget developers, and considering the $109 price tag on VB.NET Standard, i thought they would go hand-in hand. apparently not.
i can connect to the database programmatically just fine, but the inability to do it visualy is very dissapointing
any help is appreciated.
stephen
|
|
|
|
|
medicenpringles wrote:
but the inability to do it visualy is very dissapointing
You're not missing much. I prefer to do my database work in the Enterprise Manager of SQL Server anyway. Hand coding the database code is a much cleaner approach. All your code is contained to exactly where you put it instead of where the Designer wants to put it.
The Standard Edition of Visual Studio won't connect the Server Explorer to SQL Server. It's limited to the desktop databases only. Visual Studio Professional and above will work though.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
well to be honest, the only real reason i got Developer Edition was for the enterprise manager. if i only used the free Desktop Engine, would Enterprise Manager sill work with maintaining the databases on the Desktop Engine?
|
|
|
|
|
Frankly, I've never tried it. I think it would work, but it might take a couple of hacks to get it there.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi,
I have been working purely as a web developer for some time. My boss now wants me to create my next project as a windows application (VB.NET), which I have never done! My question is what sort of things should I be aware of? I will be using databases, are these treated differently?
Thanks
|
|
|
|
|
Anonymous wrote:
I will be using databases, are these treated differently?
Nope. Data is data. If your application is written correctly into tiers, then you could quite easily use the same business rules and data access classes between an ASP.NET version and a Windows Forms version of your app. There's not too much different from ASP.NET. It's still an event driven model.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I have a picturebox that has been populated with an image. I need to determine the path/filename of the image being displayed in the picurebox. Does anyone know of the property that contains the path and filename of an image displayed in a picturebox?
Thanks
Keith
|
|
|
|
|
There is no way to determine this. Not all Images or Bitmaps are created from files, so it's of little use.
Since you loaded the picture box from a file, you've already got the filename. It's just not attached to the Image object. I think your problem will be solved if you exposed your data, like the currently loaded filename, in the correct manner.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Please help me, I've lost my mummy.
I am a class , which inherits a tabpage.
I have a procedure in my tabpage class which needs to update other controls outside of my tabcontrol inwhich i sit.
For example, my tabpage class is within a tabcontrol which is in a form that also has a statusbar.
How can I find it?
I tried doing:
<br />
me.parentform.statusbar1.text = "Loading"
But that doesnt quite work out.
I tried doing:
<br />
dim fmain as Mainform<br />
fmain = ctype(me.parentform,MainForm)<br />
<br />
fmain.statusbar1.text = "Loading"
but that never worked out either.
Is there another way?
|
|
|
|