|
Hi,
My MainForm is set as a MDI Parent and I have a number of MDI Child Forms. However, I have a problem with one of the MDI Child forms containing a PictureBox.
I am drawing my graphics offscreen (a large background jpg image onto which I draw some additional items, using GDI+), I then using BitBlt to Paint a portion of this image inside the PictureBox. (The mouse is then used to scroll the image).
If I dont have this form set as a MDI Child all works beautifully. However, when set as a MDI Child, problems arise. The image is not drawn on load and only appears when I move the mouse inside the PictureBox (as if to scroll). If I minimise the form and then maximise it - again no image appears until I move the mouse again.
My guess is that it has something to do with the Paint Event - I did read on MSDN that there is a problem with the Paint Event on MDI Children if the Opacity Property is used on the Child Form. I have left this at the default value of 100%.
Any help or suggestions would be most welcome.
Thanks,
NagaJim
|
|
|
|
|
Hi,
I need to create a crystal report in vb.net. Some fields can be pulled from database and some needs to be entered by the user. So i need to put editable text boxes in the report.
Can this be done?
|
|
|
|
|
is this anything you'd be able to handle with input parameters?
-jim
|
|
|
|
|
How do you get the correct location of the control? if it is inside a FORM within a PANEL within a GROUPBOX ?
Is it POSSIBLE to get the absolute location of the control (no matter inside of where it is?).
I want to overwrite the control with a new control.
Thanks
|
|
|
|
|
You can use left and top properties, from the microsoft reference:
Control.Left Property [Visual Basic]
Gets or sets the x-coordinate of a control's left edge in pixels.
[Visual Basic]
Public Property Left As Integer
[C#]
public int Left {get; set;}
[C++]
public: __property int get_Left();
public: __property void set_Left(int);
[JScript]
public function get Left() : int;
public function set Left(int);
Property Value
The x-coordinate of a control's left edge in pixels.
Remarks
The Left property value is equivalent to the Point.X property of the Location property value of the control.
Changes made to the Width and Left property values cause the Right property value of the control to change.
|
|
|
|
|
Yeap...Itried it it does not work.
I want the absolute position of the control.
(I want to overwrite the control)
when I try to overwrite the control using control.left or control.top and the control is within a panel it does not locate it correctly.
here is some of my code
newcontrol.left = oldcontrol.left
newcontrol.top = oldcontrol.top
oldcontrol.sendtoback
newcontrol.bringtofront
my newcontrol is set relative to the form1 not relative to my panel1 .
|
|
|
|
|
I know that...thanks
but, the point is:
I would like to get (there must be a way) the absolute positioning of the control.
|
|
|
|
|
i would say after reading your thread that the most likely problem is that you're not adding the newcontrol to the groupboxes controls collection.
a control's position property is always relative to it's immediate parent. so if you have oldControl on a panel and assign it's left property a value of 5, it will be 5 pixels (twips) off of the panel's left edge. if you have newControl directly on the form and assign it's left property a value of 5 it will appear 5 pixels off the forms left edge.
give this a try...
dim newControl as new textbox
myGroupBox.Controls.Add(newControl)
newControl.Top = oldControl.Top
newControl.Left = oldControl.Left
another way to do this would be to just create both controls at design time and position them as you wish. then at run-time all you have to do is add the code to handle hiding/showing them appropriately.
hope this helps,
-jim
|
|
|
|
|
thanks, I got some light now.
I beleive I AM adding newcontrol to the FORM1; I should added to the Panel1 inside FORM1. how do I add newcontrol into FORM1.PANEL1 form FORM2.
|
|
|
|
|
Seems we finally understood:
Dim TextBox1 As TextBox = New TextBox()
Dim ctr As New Control
for each ctr in me.parentform.controls
if ctr.name="Panel1" then
'instructions
ctr.add(TextBox1)
end if
next
|
|
|
|
|
well, the best way to do it depends on exactly what the relationship between these two forms is.
if form1 is the mdi parent of form2...
'in formTwo...
dim formOne as form1 = me.MdiParent
if form1 is set as the parent control of form2 through the .Show() procedure...
'in formTwo...
dim formOne as form1 = me.Parent
the above code will give you an instance of form1, which you'll then need to utilize to add your control.
my recommendation for doing this would be having a friend Sub to grant access for you to the controls property of the panel.
public class form1
inherits system.windows.forms.form
'--- windows generated code ---'
Friend Sub AddPanelControl(byval controlToAdd as Control, byval location as System.Drawing.Point)
me.panel1.controls.add(controlToAdd)
controlToAdd.Location = location
End Sub
End Class
public class form2
inherits System.Windows.Forms.Form
Private Sub button1_click(byval sender as object, byval e as buttonclickeventargs) handles button1.click
dim formOne as form1 = me.mdiparent 'you may need to cast this return value using ctype depending on whether or not you're using option strict on...
dim newControl as New TextBox
With newControl
.Name = "myTextBox"
.Text = ""
'etc.
End With
formOne.AddPanelControl(newControl, new System.Drawing.Point(10, 10))
End Sub
End Class
This should work out for you. I haven't tested it out or anything, but let me know if there are problems.
I would still recommend setting your controls at design time and just worrying about managing their visibility, but if you can't then this would be another way...
-jim
|
|
|
|
|
JIM:
Thanks, very close.
this is what I have.
FORM1 has the array of controls (all textbox inside a PANEL1)
lets say:
textbox1
textbox2
textbox3
when we click a control let's say textbox2:
Form2 will overwrite the control textbox2(hide The control from FORM1) and
creating the new Textbox2 (could be any type of cotrol: a textbox or Calendar or whatever) in the location where textbox2 was.
now, FORM2 has to create the control reading from a DB at run time and overwrite the one form FORM1.
If you can give one more tip...THE CREATE STATEMENT
I need to say FORM1.PANE1.CONTROLS.ADD(newcontrol) from FORM2
i DONT KNOW HOW ?
I appreciate your help.
Thanks
|
|
|
|
|
forgot!
FORM1(Is not mdiparent) does the call only by:
dim f2 as new form2
f2.loadFld(me,textbox2)
and
FORM2 has:
Public Sub Form_Load(ByVal pf2 As Form, ByVal t1 As TextBox)
|
|
|
|
|
that is what the freind sub AddPanelControl is for. in general it's nota good idea to expose properties of child controls to external resources. therefore a buffer that can control access to an exposed field can limit who, or what can access the exposed field. for instance, since the sub AddPanelControl is declared as Friend, it restricts access to only objects declared in the same project as the procedure.
so from form2 you can AddPanelControl and pass in the newcontrol you want added to the panel. the problem you're going to run into with this architecture is that you're not going to be able to destroy the initial control; or textbox1.
this is why i recommended going with a solution whereby you set everything at designtime and just check a variable state to determine the visibility of certain controls.
honestly, from your description i still don't understand exactly what you want to do.
you have a form 'form1' with a panel and for example several textboxes. when you click on textbox1 on form one you want to have form2 replace textbox1 on form1 with another control? i don't understand how this is going to work...
am i misunderstanding you?
maybe if you post the relevant code that you have from form1 and form2 i can try to figure something out.
-jim
|
|
|
|
|
FORM2 (which will be a new project) will handle all the routines for to the new textbox2 (checking and validating).
This is what I need/want to do:
We have 202 forms with diff entry fields for ea reports (CR v10).
These entry fields can be chkbox, list ,combos, and so on.
ea form could have a mix of fields as datefrom,dateto,idfrom,numfrom,numto and many more fields.
Forms can have any of these fields and ea field will have to be validated.
in a case of a IdFrom will have to have a list for the user to select from. I think I can avoid doing 202 forms if...
If I create a general FORM1 with text boxes representing ea field entry, then, when the user clicks on one of the textbox I will know what form to call and handle all the related to such field and validate such field.
So, ea field will have a Procedure to handle all related to the field (err msg,edits,checking range values or any other need).
if we have one form for ea report we have to repeat too much code.
neither, I cannot have all these code in a single form, it will be too much debugging.
|
|
|
|
|
Hi
I'm trying to implement the authorization and profile application block for my application, i really don't know from where to start
Any help
Thanks in advance
TG
|
|
|
|
|
tigertwareg wrote:
i really don't know from where to start
The documentation and QuickStart samples with this ApplicationBlock would probably be a good place to start, don't you think?
|
|
|
|
|
Hi,
Thanks for help, I've done what u told me, it really helps thanks a lot,
i still have a problem, i'm using active directory, i do the following:
i change my store location in the app.config of my project like this:
<storelocation>msldap://CN=SecurityStore,DC=Myserver
SecurityStore : is my store in the autorization manager on the server
Myserver : is the name of the server
and i have this error:
Additional information: COM object with CLSID {B2BCFF59-A757-4B0B-A1BC-EA69981DA69E} is either not valid or not registered.
if u can help
thanks in advance
|
|
|
|
|
How do you access a winform in CLASS FORM1 from CLASS FORM2 (form1 is calling form2)?
this is what I would like to do.
FORM1 will have the winform .
FORM2 will have the controls to create at run time...this controls will show on the screen of Form1.
So far what I have:
FORM1 is calling FORM2 as
popForm1.form_load(Me)
and in FORM2 I am trying creating the controls:
Public Sub form_load(ByVal pf2 As Form)
dim NEWCTRL as new textbox
NEWCTRL.name = "ctrl1"
...
HERE IS WHAT i WANT FORM1.panel1.CONTROLS.ADD(NEWCTRL)
the FORM1 has a Panel1 that I dont know how to add my newctrl to FORM1.PANEL1
THANKS
|
|
|
|
|
If I understood you want to open a form inside another form, to do this you should set the Form1 property IsMdiContainer to true.
Then I use this code to manage the opening:
Dim MyForm As New Form1
MyForm.MdiParent() = Me
MyForm.Show()
If you want to access from child form to parent : me.parentform.
I'm neewie, I hope not to confuse instead help
|
|
|
|
|
thats all about trying...
Yeap, it is correct what you said, but I want to refer to the controls of FORM1 from FORM2.
how do you get to change one of the properties of any control of FORM1 while you are in FORM2.
|
|
|
|
|
just about right...
try to refence Me.ParentForm1.textbox from FORM2...
that's the How do I do that.
what do you pass as a param to FORM2.
|
|
|
|
|
If you want to add a control:
Me.ParentForm.Controls.Add(value as system.windows.forms.control)
------------
If you know the control's name (Textbox1) you can use the for... next as i wrote.
Dim ctr As New Control
for each ctr in me.parentform.controls
if ctr.name="ControlIwantTochange" then
'instructions
ctr.text="Whatever"
end if
next
------------
If you want to change every control:
For Each ctr In Me.Parentform.Controls
Select Case UCase(thisObj.GetType.Name)
Case "TEXTBOX"
'code
end select
next
|
|
|
|
|
|
' Make popup form reference public
' Make Panel Control Public on the popup form
now fom here you can do
popupform.panelcontrol.controls.add (NewCTRL)
Rizwan Bashir
|
|
|
|