|
example:
suppose i have 3 forms
and sequence of opening is form1->form2->form3
form1 is MDi parent, form3 is MDi child
on clickin of form1, form2 gets open which takes some values from user retreives the data and accordingly opens form 3..
ma doubt is from form1, form2 can b made mdi child
but from form 2, how form3 will b made child of form1..???
thanks
|
|
|
|
|
From form2 use the following
Dim form As New Form3
form.MdiParent = Me.MdiParent
form.Show()
</code>
-- modified at 21:24 Tuesday 9th October, 2007
Mike Lasseter
|
|
|
|
|
its not working man...
form3 is not becoming child of form1..
|
|
|
|
|
Yes it does work. The code I pasted should be run on form2. Paste you code for each form and I will tell you what you are doing wrong.
Mike Lasseter
|
|
|
|
|
i am using VS 2005.
when i am writin this code in button click event of form2,
form 3 gets open but not as a child of form1..
it opens as individual form...
|
|
|
|
|
The code I posted works, post your code for each form.
Mike Lasseter
|
|
|
|
|
form1 is mdiparent with ismdicontainer as true
coding for form1
button_click event<br />
dim frm2 as new form2<br />
frm2.show()<br />
now in button click event in form2
<br />
dim frm3 as form3<br />
frm3.mdiparent=me.mdiparent<br />
frm3.show()<br />
this was your method..
the method which i am using is in form2 i code
button_click()<br />
dim frm3 as new form3<br />
frm3.mdiparent= form1<br />
frm3.show()<br />
this one works but only when form1 is startup form.
if form1 is any intermediate form and startup form is any other form then this method doesnt works..
any solution..??
thanks
|
|
|
|
|
You are right, I misread your post and thought Form2 was an MdiChild of Form1 as well.
I don't understand why you would ever use the scenario in your post. Generally, with Mdi applications you don't create forms that are not MdiChildren or Dialog forms (dialog forms must be closed before you can do anything else in the application, like the MessageBox). The reason for this is all your forms are neatly contained in the main application instead of spread out across your machine. But you know what you are trying to do better than me, just hope I was able to offer something helpful.
Mike Lasseter
|
|
|
|
|
I want to create a tab dynamically and put a browser control in it.
BiG RaLpH
|
|
|
|
|
Dim newPage as New TabPage()
newPage.Controls.Add(New WebBrowser())
yourTabControl.TabPages.Add(newPage)
That's about the simplest form of it.
The early bird who catches the worm works for someone who comes in late and owns the worm farm. -- Travis McGee
|
|
|
|
|
now how can I access it?
BiG RaLpH
|
|
|
|
|
there a few possible ways:
1) declare the control you want to access global (dim w as webbrowser)
when you create it you first need to initialize it ( w = new webbrowser)
this way you can access the control from anywhere (always check first if it has been initialized ( if w isnot nothing then 'do you're code))
2) when you create the control give it a unique name (w.name = "unique")
then when you want to access it you can just run true the controls on you tabcontrol (normally all tabpages) and for each tabpage run true his controls and compare name
(if control.name.tolower.equals("unique") then ' do you're code)
this is a bit more work and I think it's better to use the first option (for performance) but it should also work
hope this helps
If my help was helpfull let me know, if not let me know why.
The only way we learn is by making mistaks.
|
|
|
|
|
Hello all!
I'm having a complicated problem here, here goes;
At my development workspace, im running on Vista, VB .net 2005 and the DB on SQL Express 2005. Now i would normally insert a date value as such;
INSERT INTO Table(DateColumn) VALUES ('" & "yyyymmdd" & '")
The date that is in yyyymmdd format without slashes in between, and its in a string format.
As far as it is, it works well.
But now my problem is, when I tried my program on another system (Windows XP), I couldnt be able to insert a date in such a way, an error states that 'unable to convert to smalldatetime ..etc'
ive' tried changing my method to as such,
INSERT INTO Table(DateColumn) VALUES (" & dateValue.Date & ")
it works, to most extent, but the weird part is, some areas in my program dint turn out to work as well as it's expected. The values are inserted into the DB but its showing "1/1/1900" ! As mentioned, using the same identical method on other areas dint have a problem.
What should I do? Why couldnt I in the first place, replicate the success I had over with my Vista workspace onto the other PC. (2 in fact, both running on XP).
Should I define how the database should accept date values? or?
Thanks in advance! Do need some advices here..
Regards,
Jensen
|
|
|
|
|
This is the problem with using string concantenation to build SQL query statements. Convert this to a parameterized query and you shouldn't have a problem with it at all.
Read SQL Injection Attacks[^] and it'll explain what a parameterized query is.
|
|
|
|
|
I know about creating parameterized queries but ive used it only at certains areas in my program.
I dint know its significant until now! It's really odd and I wouldn't have known if I dint come in here and asked!
Thanks once again!
|
|
|
|
|
Have you tried something like this:
INSERT INTO Table(DateColumn) VALUES (cast '" & "yyyymmdd" & '" as date)
You always pass failure on the way to success.
|
|
|
|
|
yes, but it works on some statements and wouldnt work the other half, its oddly strange but ive used the method specified by Dave ( see above ). It works, guess from now, ill just build all my statements using parameters.
but thanks for the suggestion!
|
|
|
|
|
maybe this is not really a problem with your SQL statement:
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim dt As New DateTime
Console.WriteLine("New Date {0}, Year={1}, Month={2}, Day={3}", dt.ToString("yyyy/MM/dd"), dt.Year.ToString(), dt.Month.ToString(), dt.Day.ToString())
End Sub
what does your db do with "empty" dates?
|
|
|
|
|
I’m working on creating a Visio 2003 organization chart over .net, I have been code it by using VB.Net 2005. What I’m trying to do is to retrieve the organization chart hierarchical from the database and store it as an html web page. I have been used the organization chart wizard for creating the chart shapes and I used VisSaveAsWeb object to save the chart as a web page. My problem is that the org chart shapes doesn’t formatted correctly after resizing the shapes to fit with it text. Is there any one know how could I control the shape position to relocate it into it right place
and this is my peace of code
Code Block
'On Error GoTo OrgDoItErrHandler<br />
<br />
Dim objVisio As Visio.Application<br />
<br />
Dim objAddOn As Visio.Addon<br />
<br />
Dim vsoSaveAsWeb As VisSaveAsWeb<br />
<br />
Dim vsoWebSettings As VisWebPageSettings<br />
<br />
Dim strCommand As String<br />
<br />
Dim i As Integer<br />
<br />
Dim pagObj As Visio.Page<br />
<br />
Dim shpObj As Visio.Shape<br />
<br />
Dim celObjHeight As Visio.Cell<br />
<br />
Dim celObjWidth As Visio.Cell<br />
<br />
<br />
<br />
strCommand = "/DATASOURCE=SN,TABLE=" _<br />
<br />
& "~" & ",DBQUALIFIER=~" _<br />
<br />
& " /NAME-FIELD=~" _<br />
<br />
& " /UNIQUEID-FIELD=~" _<br />
<br />
& " /MANAGER-FIELD=~" _<br />
<br />
& " /DISPLAY-FIELDS=~" _<br />
<br />
& " /CUSTOM-PROPERTY-FIELDS=~" _<br />
<br />
& " /SHAPE-FIELD=~"<br />
<br />
<br />
<br />
objVisio = New Visio.InvisibleApp<br />
<br />
<br />
<br />
objAddOn = objVisio.Addons.ItemU("OrgCWiz")<br />
<br />
<br />
<br />
'Run the add-on (errors are handled by the add-on)<br />
<br />
On Error Resume Next<br />
<br />
<br />
<br />
'Break up the string<br />
<br />
Dim strCommandPart As String<br />
<br />
Dim strCommandLeft As String<br />
<br />
strCommandLeft = strCommand<br />
<br />
objAddOn.Run("/S-INIT")<br />
<br />
While (Len(strCommandLeft) > 0)<br />
<br />
strCommandPart = Microsoft.VisualBasic.Left(strCommandLeft, MAX_ARGSTRING_LENGTH)<br />
<br />
strCommandLeft = Mid(strCommandLeft, Len(strCommandPart) + 1)<br />
<br />
objAddOn.Run("/S-ARGSTR " + strCommandPart)<br />
<br />
End While<br />
<br />
objAddOn.Run("/S-RUN " + strCommandLeft)<br />
<br />
<br />
<br />
' Get a VisSaveAsWeb object that<br />
<br />
' represents a new Web page project.<br />
<br />
vsoSaveAsWeb = objVisio.Application.SaveAsWebObject<br />
<br />
' Get a VisWebPageSettings object.<br />
<br />
vsoWebSettings = vsoSaveAsWeb.WebPageSettings<br />
<br />
' Configure preferences.<br />
<br />
With vsoWebSettings<br />
<br />
.StartPage = 1<br />
<br />
.EndPage = 2<br />
<br />
.QuietMode = True<br />
<br />
.TargetPath = "D:\Balaji\Test.htm"<br />
<br />
.SilentMode = True<br />
<br />
End With<br />
<br />
<br />
<br />
pagObj = objVisio.ActivePage<br />
<br />
<br />
<br />
' I’m trying here to resize the shaps to fet with the texts that inside it<br />
<br />
<br />
<br />
For i = 0 To pagObj.Shapes.Count<br />
<br />
If pagObj.Shapes.Item(i).Name.Contains("Executive") Or pagObj.Shapes.Item(i).Name.Contains("Manager") Or pagObj.Shapes.Item(i).Name.Contains("Position") Then<br />
<br />
pagObj.Shapes.Item(i).CellsSRC(1, 1, 0).FormulaForceU = "4.25 in"<br />
<br />
pagObj.Shapes.Item(i).CellsSRC(1, 1, 1).FormulaForceU = "9.15625 in"<br />
<br />
pagObj.Shapes.Item(i).CellsSRC(1, 1, 3).FormulaForceU = "1.6875 in"<br />
<br />
End If<br />
<br />
Next i<br />
<br />
<br />
<br />
' Create the pages. Because no particular document<br />
<br />
' is specified, the active drawing is saved.<br />
<br />
<br />
<br />
vsoSaveAsWeb.CreatePages()<br />
<br />
<br />
<br />
objVisio.ActiveDocument.Saved = True<br />
<br />
objVisio.ActiveDocument.Close()<br />
<br />
objAddOn = Nothing<br />
<br />
objVisio.Quit()<br />
<br />
objVisio = Nothing<br />
<br />
<br />
<br />
Exit Sub<br />
<br />
<br />
<br />
OrgDoItErrHandler:
i try to learn programming what ever i had i feal that i did'nt get anything
|
|
|
|
|
I have a database (sql server 2000) is suspect, please help me, thanks.
|
|
|
|
|
Phan Van Thao wrote: I have a database (sql server 2000)
Congratuations...
Phan Van Thao wrote: database (sql server 2000) is suspect,
And that means what exactly?? Suspects of what??
Phan Van Thao wrote: please help me, thanks.
Can't. You haven't supplied any information about what the problem is.
|
|
|
|
|
This is more of a SQL question.
I have come across this situation myself and my suggestion is to try and detach and then re-attach the database in Enterprise Manager - this sometimes fixes the issue.
I don't want to recommend deletion of log files etc as I don't want to be held responsible for loss of data.
Googling the issue bought this up:
A database can be marked for many reasons. Generally it falls into the following conditions :
* A database or log file is missing.
* In SQL 6.5, a device may not be present or in 7.0/2000 a file may not exist.
* SQL Server may not have been able to restore the database in ample time.
* The database could be corrupt.
* The database is being help by the operating system. This could be a 3rd party backup software or defrag software. I've had even a virus scanning software cause this once.
* SQL Server does not have enough space to recover the database on startup.
You always pass failure on the way to success.
|
|
|
|
|
what r the properties to change the progressbar forecolor and backcolor
|
|
|
|
|
There are no properties for this. If you want to change the appearance of the ProgressBar, you're going to have to create your own version of it. Create a new class that inherits from ProgessBar and add the properties and code for BackColor, ForeColor, and all the drawing code to custom draw the control.
|
|
|
|
|
Hola,
I am working on a tool that from one side connects to a simulation model using ActiveX and to the other side to a control system via Sockets.
The only thing the tool should do is making connections to both parties (simulation model and real controls) and send message through between the two components.
For the socket side of the tool I made this code with a lot of copy pasting from websites (see below). But it doesnt work... A connection is made, but receiving and sending is not working. I dont understand what to do with the receive function (which parameters). I only want to receive a string (size 100) through the connection. Sending seems to work because the real controls get stuck when I call the SendMessage sub.
Another question is how I can automatically react on a incoming message instead of checking this every 0.1 sec (I call the sub every 0.1 sec). Is there an event defined that wakes up when incoming data arrives?
Please help.
Imports System<br />
Imports System.Text<br />
Imports System.IO<br />
Imports System.Net<br />
Imports System.Net.Sockets<br />
Imports Microsoft.VisualBasic<br />
<br />
Public Class MySockets<br />
<br />
Dim Listener As Socket<br />
Dim Sender As Socket<br />
Public Function ConnectSocket(ByVal server As String, ByVal port As Integer) As Socket<br />
<br />
<br />
Listener = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)<br />
<br />
' bind the listening socket to the port<br />
Dim hostIP As IPAddress = Dns.Resolve(IPAddress.Any.ToString()).AddressList(0)<br />
Dim ep As New IPEndPoint(hostIP, port)<br />
Listener.Bind(ep)<br />
<br />
' start listening<br />
Listener.Listen(1)<br />
<br />
Sender = Listener.Accept()<br />
<br />
Return Sender<br />
End Function<br />
<br />
Public Sub SendMessage()<br />
<br />
Dim Data As String<br />
Data = "HolaHola"<br />
<br />
Dim msg As Byte() = System.Text.Encoding.ASCII.GetBytes(Data)<br />
<br />
Debug.Print(Sender.Connected)<br />
Sender.Send(msg)<br />
End Sub<br />
<br />
Public Sub ReceiveMessage()<br />
Dim vbBytes As Int32<br />
Dim buffer As Byte()<br />
Dim vsString As String<br />
vbBytes = Listener.Receive(buffer)<br />
<br />
vsString = Encoding.ASCII.GetString(buffer, 0, vbBytes)<br />
End Sub<br />
End Class
|
|
|
|