|
You can insert one managed Form into another by setting the former's TopLevel property false, and its Parent to the latter. You need to do something equivalent to Word's main form (which isn't a managed Form).
So this is what I would try: open the Word process with Process.Start, then invite its main window into your Form by setting its parent (use P/Invoke to call SetParent[^] in user32.dll); I don't know about the native support for TopLevel, I can only hope you won't need it.
Here is my first try in VB.NET:
Private Sub btnWord_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWord.Click
Dim p As Process = Process.Start("H:\test.doc")
Dim word As IntPtr = p.MainWindowHandle
Dim panel As IntPtr = Me.Panel2.Handle
SetParent(word, panel)
End Sub
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Public Shared Function SetParent(ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As IntPtr
End Function
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
modified on Tuesday, May 3, 2011 7:37 AM
|
|
|
|
|
No way.
VB.NET doesn't support this.
Only by opening word.
|
|
|
|
|
you can open MS Word (or any other app) inside your managed form, as I already told him days ago. Of course it needs Word, but it does not need a separate main window.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Hi Luc,
yes, I agree, your solution works. But you are opening the word application and you just set a new parent to the word main form.
My understanding of the question was, just to open the word document inside a vb.net form (or any other form). Richtextbox (or any other control) can not open a worddocument. So is seems to be impossible just to open a word document for display similar to a richtext file in a richtextcontrol.
regards,
bauer
|
|
|
|
|
So i have a basic idea of an application i want to build in my head. It involves having to add a menuitem to the Shell/Explorer ContextMenu of Windows. Here's how it should work.
1. On first time use, you are to install the menuitem by clicking a button. There's also an uninstall button to remove the menuitem from the shell contextmenu.
2. Then, once it's installed, this menuitem only shows up when you rightclick on one or more files with the .bsp file extension.
3. When you have one or more bsp files selected, you rightclick on one of them to make the contextmenu appear. From there, you click the new menuitem.
4. Then i want a form to show up with a listbox. This listbox should hold the full paths to the bsp files that the user had selected.
I got as far as point 3 and im stuck on point 4. How do i go about getting the paths of the selected bsp files into the listbox on that form?
Virtual Space Shuttle Astronaut
|
|
|
|
|
Nobody knows? There must be way to get this to work.
Im able to retrieve commandline arguments using the %1 parameter, but if i select more than one bsp files and click the menuitem in the explorer contextmenu, Windows launches multiple instances of my application. I just want it to start once, and add the path of all the selected bsp files added to a listbox.
I've also tried the %2, %PATH% and %L parameters but none of them work.
Virtual Space Shuttle Astronaut
|
|
|
|
|
Hi,
Earlier I used only Crystal reports. I never used any RDLC reports. Now I try to use it in VS2010.
As like usual I added one Dataset [xsd] and it contains Datatable1.
Now How can I use this Dataset1? & DataTable1.?
And from my program Button1_Click
Dim MyDtbl1 As New DataTable, NRow As DataRow
MyDtbl1.Columns.Add("one", Type.GetType("System.String"))
MyDtbl1.Columns.Add("two", Type.GetType("System.String"))
MyDtbl1.Columns.Add("three", Type.GetType("System.String"))
For J As Integer = 0 To 10
NRow = MyDtbl1.NewRow
MyDtbl1.Rows.Add(NRow)
MyDtbl1.Rows(J).Item("one") = J + 1
MyDtbl1.Rows(J).Item("two") = J.ToString
Select Case J
Case 0
MyDtbl1.Rows(J).Item("three") = "zero"
Case 1
MyDtbl1.Rows(J).Item("three") = "one"
Case 2
MyDtbl1.Rows(J).Item("three") = "two"
Case 3
MyDtbl1.Rows(J).Item("three") = "three"
End Select
Next
ReportViewer1.Refresh()
ReportViewer1.LocalReport.ReportPath = "C:\CodeProject\My Documents\Visual Studio 2010\Projects\MyReportPjct\MyReportPjct\Report1.rdlc"
ReportViewer1.LocalReport.DisplayName = ?????
ReportViewer1.LocalReport.DataSources.Clear()
Dim MyRptDtSource As New Microsoft.Reporting.WinForms.ReportDataSource
MyRptDtSource.Name = ???????????
MyRptDtSource.Value =???????????
ReportViewer1.LocalReport.DataSources.Add(??????)
ReportViewer1.LocalReport.Refresh()
ReportViewer1.Visible = True
Any Ideas For Me !!!
Thanks & Regards
PARAMU
|
|
|
|
|
Anyhow I found the answer and let it be useful to someone like me....
ReportViewer1.RefreshReport()
Dime RpDs1 As New Microsoft.Reporting.WinForms.ReportDataSource
'Here We have to mention the actual Report's Dataset Name
RpDs1.Name="DataSet1"
RpDs1.Value=MyDtbl1
ReportViewer1.LocalReport.ReportPath="C:\CodeProject\My Documents\Visual Studio 2010\Projects\MyReportPjct\MyReportPjct\Report1.rdlc"
ReportViewer1.LocalReport.DataSources.Clear()
ReportViewer1.LocalReport.DataSources.Add(RpDs1)
ReportViewer1.RefreshReport()
ReportViewer1.Visible = True
Regards
PARAMU
|
|
|
|
|
Hello,
I was reading an artical and there was a line of syntax I hadn't seen
before and I'm curious what is it doing behind the scenes:
Dim v as single = 2293.22
Dim sh as short = New Short?(v)
Short doesn't have a constructor so how did the '?' allow it?
Thanks.
Nathan
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
|
|
|
|
|
|
I guess that was simple. thanks.
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
Erik,
Re-looking it, it obviously has something to do with nullable types but do you have
any idea why declaring it as nullable allowed a constructor?
Thanks,
Nathan.
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
|
|
|
|
|
Yes, declaring a variable as Nullable(of T) is the same as using T?, where T would be the underlying value type, so for example:
Dim s as Nullable(Of Short)
Dim s as Short?
These two declarations are equivalent. The reason why you can use a constructor is just becouse Nullable(Of T) has one. Replacing Nullable(Of T) with the underlying T? does not change that fact. Here in spain just call it a "syntactical sugar".
|
|
|
|
|
Very helpful. Thank you for the explanation.
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
|
|
|
|
|
That's very interesting. I have never seen that either.
|
|
|
|
|
1
-- modified 28-Nov-12 4:08am.
|
|
|
|
|
Hi Vijay,
You seem to have everything you need here, what exactly is the question ?
Regards,
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
Hi,
Can anyone guy me on how to proceed in the simplest way how to incorporate a help section inside a small project using vb.net. What I mean is that on a form, there will be a help icon to explain to the user on how fill the form...I want that to show as a pop up window to the particular help question link resides inside a help file in the form of a word document.
Hope I am clear on my question..
Thanks in advance..
|
|
|
|
|
|
Thanks, I looked at the document it is not exactly what I want to do.
Snippet:
let's say the I am a registration form. I click on a help icon, it will explain on how to fill out the registration form thru a text document. this text document is like a user manual. for each help icon, it will take the user to its respective text in this document.
thanks again
|
|
|
|
|
Look at the discussion here[^]. It is in c#, but you should get an idea how to open a word document and go to a bookmark. Hope this helps.
|
|
|
|
|
Hi everyone,
I have a question. I'm working on a database, everything is working well but i have a problem with my search function.
I want to search between 2 dates. Start date & End date and also with some user information.
For example:
Name: John
Address: Flowerstreet 25
Startdate: 25/01/2011
Enddate: 28/01/2011
So i want find all records of John between 25 & 28 january.
This is my code, its not working well, because i get everything records that i dont want.
SQLquery = "Select * from Posts where firstname like '%" & firstname.Text & "%' and " _
& "address like '%" & address.Text & "%' and startdate between #" & startdate.Text & "# AND #" & enddate.Text & "# OR enddate between #" & startdate.Text & "# AND #" & enddate.Text & "#"
Its working but like i said, my results are not the one that i want.
Can anyone
|
|
|
|
|
First, stop using string concatentation to build your SQL query. Second, Google for "vb.net parameterized sql query" for examples on how to do this using parameter objects instead of building a string query.
|
|
|
|
|
Thank you for answering so quick.
Can you please tell me what you mean with string concatentation and can you show me a small example to do it better or just tell me what i have to look for. Or is it related to parameterized sql query?
Thank's again!
|
|
|
|
|
String concatentation is appending smaller string together to build a bigger one:
Dim x As String = "Part 1" & " Part 2"
This is as far as I'm going to go to give you examples: Click Me[^]
It's up to you to do the work to teach yourself something new.
|
|
|
|