tiff Image not displaying in form2 - vb.net

I'm Trying to display image from form1 to form2 but it is not displaying.
Actally i'm using Kodak image edit control to display image .In form1 the image displayed halfly so i putted the button to display full image in form2 but it is not working.
"ImgEdit.Image" reading the value of image from form1.
Code under FullZoom Button Click:
vb.net
Dim imagename As String
Dim form2 As New form2
imagename = ImgEdit.Image
form2.ImgEdit1.Image = imagename
form2.ShowDialog(imagename)

Related

How to give focus to the new instance of a form?

I've a program in vb .net with a form named Form1. The form has button when I click on the button a dialog window appears. The dialog window has two buttons OK and Cancel. When the OK button is clicked a new instance of Form1 is created and the new instance is shown. See below code.
Private Sub ButtonOK_Click(...) Handles ButtonOK.Click
Dim frm1 As New Form1
frm1.Show()
End Sub
The problem is when a new Form1 is created by the above code, the previously created Form1 gets focused and the newly created Form1 looses focus. But I want the newly created (latest) Form1 to get the focus. How do I do it?
I have an application that I need to force the user to input information on a new form before proceeding. You can force the new form to show on top and give it focus by doing the following.
Dim frm1 = New Form1()
frm1.Show()
frm1.WindowState = FormWindowState.Normal
frm1.BringToFront()
frm1.TopMost = True
frm1.Focus()

Show dragged item while dragging vb.net

I'm wanting to show the dragged control while dragging in my form. I have a list of controls (textboxes and a picturebox) which are draggable. I would like to show the dragged control all the time, as long as the control is being dragged, even if the user cannot drop it. I also have an issue with dragging the picture box. It shows a dragged image of the control, however it flickers.
Code for drag feedback for picture box
Private Sub qrCode_GiveFeedback(ByVal sender As Object, ByVal e As GiveFeedbackEventArgs) Handles QRCodeDrag.GiveFeedback
Dim bitmap As Bitmap
bitmap = New Bitmap(QRCodeDrag.Width, QRCodeDrag.Height)
QRCodeDrag.DrawToBitmap(bitmap, New Rectangle(Point.Empty, bitmap.Size))
'bitmap.MakeTransparent(Color.White)
Dim cursor As New Cursor(bitmap.GetHicon)
Cursor.Current = cursor
End Sub
Any ideas?
I forgot to add
e.UseDefaultCursors = False
This solved the issue of the flicker

Remove textbox that added dynamically (VB.Net)

I am trying to delete a TextBox control (that added dynamically) in my form through Button_Click event (that I added dynamically too) but I cannot find the exact way to do it. My TextBox will added together with Button control (delete button) when a LinkLabel is clicked. So when added dynamically my textbox.name will be like textbox_1,textbox_2,textbox_3 and along with them is a Button control like btnDel1,btnDel2,btnDel3 (all placed in a Panel control).
My coding goes like this :
Private Sub Button_Click(sender As Object, e As EventArgs)
Dim button As Button = TryCast(sender, Button)
Dim textbox As TextBox = TryCast(sender, TextBox)
'In this case when btnDel1 is clicked, textbox_1 will be removed as well
If button.Name = "btnDel1" Then
PanelOthers.Controls.Remove(button)
End If
End Sub
Button is removed successfully but how do I remove the textbox too? Thanks in advance.
There are a couple ways to do this:
Attach all the relevant controls to the delete button's Tag property.
Create a user control that encapsulates the button and textbox.
Option 1: the Tag property
When you create your controls, add the associated controls to the button's .Tag property:
Dim button As Button = New Button
Dim textbox As TextBox = New TextBox
button.Tag = {textbox}
' Add the button and textbox to the UI surface
Now when the button is clicked you can loop over the associated controls and remove them too:
For Each item As Control In button.Tag
item.Dispose()
Next
button.Dispose()
Option 2: A user control
So isn't a tutorial site.. but you can do your own research on this one.
Here's a place to start: https://msdn.microsoft.com/en-us/library/c316f119%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396

Setting a value in a textbox from another form

I'm using vb.net 2013.I have 3 forms : Form1, Form2, Form3
On form1 I have a button . When this button is pressed , the form2 is open.The code inside the click event is :
Dim dlg1 As New Form2
dlg1.Show(Me)
Inside From2 I have a TextBox (Txt1) and a button .When this button is clicked the Form3 is open.The code inside the click event is :
Dim dlg2 As New Form3
dlg2.Show(Me)
Inside form3 I have a button that I use to set a value in the textbox (txt1) on Form2. I use this code :
Form2.txt1.Text="123"
The problem is that after I press the button on form3 , the textbox on form2 is empty , no value is set.
What can I do ? ( I don't want to change the way the forms are open)
Thank you !
Form2.txt1 references default instance of the form.
You are using a new instance here:
Dim dlg1 As New Form2
You either need to replace this code:
Dim dlg1 As New Form2
dlg1.Show(Me)
With
Form2.Show(Me) 'not recommended
Or cast your form's Owner to your previous form's type, and set the property (recommended):
DirectCast(Me.Owner, Form2).txt1.Text = "123"
Just open The forms with Form2.Show() , Form3.Show()
Then If you put this in your Form3 button click event " Form2.txt1.Text="123" " It will work.

Working With multiple instance of a windows form in vb.net

I have three forms (form1, form2, form3) in a windows application using vb.net
form1 has a button (button1). Onclick of button1, I want to open form2 in such a way that it can also open multiple times. I achieved this with the code below:
Dim myForm As New Form2
myForm.Show()
Now form2 has a button (button2), and a label (label1). Onclick of button2, I want to open a single instance of form3 a dialog, so I have the code below:
form3.showdialog()
form3 has a textbox (textbox1).
My problem is that I want when I fill textbox1, I want the value to appear in label1 of form2 that opened the form3, I tried the code below, but it did not work:
form2.label1.Text = textbox1.Text
I need to update form2 (the last active one) once form3 has been closed
Can anybody help me out please?
When you go to show the Form3 as a dialog, you should be able to do:
Dim f3 As New Form3
f3.ShowDialog()
Me.label1.Text = f3.textbox1.Text 'Copy the value out of the dialog