In a simple vb.net Winforms application, I can add a WebBrowser to a form and then execute:
WebBrowser1.Navigate(myUri)
Dim pageSource = WebBrowser1.Document.Body.InnerHtml
This puts the page source into a variable, whence I can parse it at will.
When I add a ChromiumWebBrowser to a form, I can view a page in an equivalent manner to WebBrowser using:
ChromiumWebBrowser1.LoadUrl(myUri)
What is the equivalent single line of code to put the current page source into a variable with ChromiumWebBrowser?
Related
In a VB.NET 4.72 WinForms project, i have placed an MDI form (MDIForm1), an MDIChild form (Form1) and a module. In the module, i have declared an extension method:
<Extension()>
Public Sub ShowChild(SourceForm As Form)
MessageBox.Show(My.Application.Culture.ToString)
End Sub
In the MDIForm's Load event, i have the following code:
My.Application.ChangeCulture(NewCultureName)
My.Application.ChangeUICulture(NewCultureName)
'NewCultureName is a string which is set to any valid value other than "en-US".
Form1.ShowChild
When debugging the project, the MessageBox that appears when ShowChild is called, displays "en-US" instead of the value of NewCultureName. If a breakpoint is placed in "Form1.ShowChild" statement, i can see that the culture has indeed changed to the value of NewCultureName. The application acts though as if there are two different instances of My.Application, one in the MDI form and another inside ShowChild. Why is this happening?
2019-04-14: Edited to a more precise description of the issue.
net and I am trying to create a project that will handle questions from a text file and save the answers to a new text file. I was searching the internet and I couldn't find an example for linking two webform through vb code so here is my problem:
I want to preprocess a text file that will be uploaded in a specific form through vb.net . That context is parsed in a string table. Now I want that table to pass over to the rest of my forms which they will handle the data in order to modify the below webform. Here is where I want to call the other forms in order.
Private Sub BtdContinue_Click(sender As Object, e As EventArgs) Handles BtdContinue.Click
If FileUpl.PostedFile IsNot Nothing Then
Dim finalTextTable(rows.Length, 4) As String
'Preprocess
'for i=0 to finalTextTable.Lenght-1
' for j=0 to 4
'Call the other web form from here in a loop if possible
End if
Here is my web form with labels and images that I want every question to change it
I also want to be able to go to the previous webform through a
previous button.
If i did understand your question correctly you are asking to redirect the data from the preprocessed text file to another form. The easiest solution i can think of is by using session variables. After you have preprocessed your text file and stored it into a dataTable you should add the following:
'Set the value of DataTable to session
Session("DataTb") = finalTextTable
'Perform your Redirect
Response.Redirect("FormB.aspx");
The above code should save the table into a session variable accessible by FormB.aspx. You can then handle the table in the second form as you wish.
I am working with Lotus Domino. When I read the xml file I want to click on a button and it displays a form to let me select the file:
Sub Click(Source As Button)
//How to file input form display here
End Sub
There's still one more problem.I read the xml file and output data is documents:
Dim reader As New XmlNodeReader
Call reader.ReadFile(datas)
documents = reader.getNodeReaders("egov.document ")
Forall document In documents
//How to display list document for my form
End Forall
Please help me in the shortest possible time.Thanks all!!!!
To display a dialog that allows you to select a file, use the Prompt method of the NotesUIWorkspace class.
The rest of your question requires knowledge of the particular XML schema you are working with.
Question: I have a form I created in Excel (Developer mode). The form has a MutliPage control on it. I am able to add a dynamically add new Page to the multipage control with VBA. I have no idea how to add any content onto this page that I have just created - for example adding a new checkbox, labels etc.
The only code I have at the moment is:
DataQueryForm.DimensionTabs.Pages.Add "MyName", "My Caption"
Dim currentPage As Page
Set currentPage = DataQueryForm.DimensionTabs.Pages(0) 'this line fails
As you can see I don't even know how to get the first Page into a variable of type Page - so it's hard to know how to begin.
Any pointers in how to add new checkboxes to the page would be most appreciated. I'm really struggling to find decent documentation on this, really, anything at this stage would be helpful.
Thanks
You need to specify MSForms.Page so you don't get a type mismatch (Excel also has a Page object) and you can set the variable as you add the page:
Dim currentPage As MSForms.Page
Set currentPage = DataQueryForm.Dimensiontabs.Pages.Add("MyName", "My Caption")
I'm trying to generate images using ImageTools, and my code works and successfully creates images...but only if I have user input before trying to create the images!
If I try to generate the images in the New sub, for example, the images are created, but they only contain the textbox control from my canvas and not the image (my control consists of text + image). So the image is being created...but it's only rendering partial content.
If I put a button on my page and generate my images from the button click even handler the images are generated correctly.
So what am I doing wrong here? And how can I get my images to generate without user input (i.e. when the app launches).
I get the exact same results using WriteableBitmap in place of ImageTools, FWIW.
I create stackpanels with a canvas and my text/image elements, then use the standard code to render the images to files in isolated storage. Since it all works perfectly after user input I don't know which parts of the code to provide...I'm basically using unmodified sample code.
Code parts (this is all in my MainPage.XAML.VB):
Public Sub New()
InitializeComponent()
' some code commented out while debugging - not relevant here
SetupHubTiles() ' this is the method that sets up the images (see below)
End Sub
The SetupHubTiles method makes several calls to the following method:
Public Sub CreateHubTile(background As StackPanel, tileImage As String, tiletoupdate As HubTile)
Dim isoStoreTileImage = String.Format("isostore:{0}", tileImage)
'Create a bitmapImage to IsolatedStorage.
Using store As IsolatedStorageFile = IsolatedStorageFile.GetUserStoreForApplication()
'Tile image's Height * Width are 173 * 173.
Dim bitmap = New WriteableBitmap(173, 173)
'Render a bitmap from StackPanel.
bitmap.Render(background, New TranslateTransform())
Dim stream = store.CreateFile(tileImage)
bitmap.Invalidate()
bitmap.SaveJpeg(stream, 173, 173, 0, 100)
stream.Close()
End Using
SetHubTileImage(tileImage, tiletoupdate) ' this is what sets a control on the MainPage to display the generated image
End Sub
And finally the button click handler (which I just implemented because the code I'm using works fine in another app, but that app always gets user input before creating images, so I figured it was the only difference between the two apps)
Private Sub StartButton_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles StartButton.Click
SetupHubTiles()
End Sub
As you can see the code being executed is identical, but I get a different result when I run it directly in my contructor compared to running it from a button click handler.
The goal is for these images to be generated at runtime (without any interaction from the user) to be used in the UI.
I've tried a few different methods of doing this, but I always get the same results - an image is generated with just text when there should be text + image. I am using the same method in other apps with the only difference being those other apps are not creating the images as soon as the app launches, which may be the problem.
It also doesn't seem to make a difference if I change the location/type of controls that I am using to build my images.
Based on your comment, try to invoke your method either later in the loading sequence or use:
Dispatcher.BeginInvoke(() => { GenerateImages(); });
This will queue the function up to be run on the next UI thread tick which should be after any pending layout work which is queued up.
The fact that you are calling this function right at the end of the constructor has no consequence (other than the fact that the variables representing different objects have been initialized). It's all happening in the same UI thread tick, before Layout is kicked off so there is nothing in the StackPanel for you to capture.
To fix this, add your code to the Loaded event of the Page and still wrap it in a Dispatcher.BeginInvoke call so that it is guaranteed to happen after all of your Controls have rendered (at least their first pass, not withstanding any content that is loaded after the startup sequence).