473,698 Members | 2,410 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

new form won't run from current thread

Ben


module main
...
application.run (new splashform)
..
end module

after a few screen, I try to load a new codes I got from MSDN on datagrid
that works on its own. I took out submain and ran datagridForm from my
mainForm:

application.run (new datagridForm)
me.hide

when mainForm comes to an end. However, nothing shows up. datagridForm ran
ok, all of the codes got executed. But nothing showed up.

I'd tried this:
datagridForm.ac tiveform.show
me.hide
however, this is even worst, datagridForm never ran at all.

Either way, nothing showed up. Could some please tell what did I do wrong?

Here is that datagridForm code I got from MSDN:

-----------------------------------------------------------------------------------
Option Explicit
Option Strict

Imports System
Imports System.Componen tModel
Imports System.Data
Imports System.Drawing
Imports System.Windows. Forms

Public Class Form1
Inherits System.Windows. Forms.Form
Private components As System.Componen tModel.Containe r
Private button1 As Button
Private button2 As Button
Private myDataGrid As DataGrid
Private myDataSet As DataSet
Private TablesAlreadyAd ded As Boolean

Public Sub New()
' Required for Windows Form Designer support.
InitializeCompo nent()
' Call SetUp to bind the controls.
SetUp()
End Sub

Private Sub InitializeCompo nent()
' Create the form and its controls.
Me.components = New System.Componen tModel.Containe r()
Me.button1 = New System.Windows. Forms.Button()
Me.button2 = New System.Windows. Forms.Button()
Me.myDataGrid = New DataGrid()

Me.AutoScaleBas eSize = New System.Drawing. Size(5, 13)
Me.Text = "DataGrid Control Sample"
Me.ClientSize = New System.Drawing. Size(450, 330)

button1.Locatio n = New Point(24, 16)
button1.Size = New System.Drawing. Size(120, 24)
button1.Text = "Change Appearance"
AddHandler button1.Click, AddressOf button1_Click

button2.Locatio n = New Point(150, 16)
button2.Size = New System.Drawing. Size(120, 24)
button2.Text = "Get Binding Manager"
AddHandler button2.Click, AddressOf button2_Click

myDataGrid.Loca tion = New Point(24, 50)
myDataGrid.Size = New Size(300, 200)
myDataGrid.Capt ionText = "Microsoft DataGrid Control"
AddHandler myDataGrid.Mous eUp, AddressOf Grid_MouseUp

Me.Controls.Add (button1)
Me.Controls.Add (button2)
Me.Controls.Add (myDataGrid)
End Sub

#if debug =1 then 'I commented this out so I could execut app..run from
mainForm
Public Shared Sub Main()
Application.Run (New Form1())
End Sub
#end if
Private Sub SetUp()
' Create a DataSet with two tables and one relation.
MakeDataSet()
' Bind the DataGrid to the DataSet. The dataMember
' specifies that the Customers table should be displayed.
myDataGrid.SetD ataBinding(myDa taSet, "Customers" )
End Sub

Protected Sub button1_Click(s ender As Object, e As System.EventArg s)
If TablesAlreadyAd ded = true then exit sub
AddCustomDataTa bleStyle()
End Sub

Private Sub AddCustomDataTa bleStyle()
Dim ts1 As New DataGridTableSt yle()
ts1.MappingName = "Customers"
' Set other properties.
ts1.Alternating BackColor = Color.LightGray
' Add a GridColumnStyle and set its MappingName
' to the name of a DataColumn in the DataTable.
' Set the HeaderText and Width properties.

Dim boolCol As New DataGridBoolCol umn()
boolCol.Mapping Name = "Current"
boolCol.HeaderT ext = "IsCurrent Customer"
boolCol.Width = 150
ts1.GridColumnS tyles.Add(boolC ol)

' Add a second column style.
Dim TextCol As New DataGridTextBox Column()
TextCol.Mapping Name = "custName"
TextCol.HeaderT ext = "Customer Name"
TextCol.Width = 250
ts1.GridColumnS tyles.Add(TextC ol)

' Create the second table style with columns.
Dim ts2 As New DataGridTableSt yle()
ts2.MappingName = "Orders"

' Set other properties.
ts2.Alternating BackColor = Color.LightBlue

' Create new ColumnStyle objects
Dim cOrderDate As New DataGridTextBox Column()
cOrderDate.Mapp ingName = "OrderDate"
cOrderDate.Head erText = "Order Date"
cOrderDate.Widt h = 100
ts2.GridColumnS tyles.Add(cOrde rDate)

' Use a PropertyDescrip tor to create a formatted
' column. First get the PropertyDescrip torCollection
' for the data source and data member.
Dim pcol As PropertyDescrip torCollection = _
Me.BindingConte xt(myDataSet, "Customers.cust ToOrders"). _
GetItemProperti es()

' Create a formatted column using a PropertyDescrip tor.
' The formatting character "c" specifies a currency format. */

Dim csOrderAmount As _
New DataGridTextBox Column(pcol("Or derAmount"), "c", True)
csOrderAmount.M appingName = "OrderAmoun t"
csOrderAmount.H eaderText = "Total"
csOrderAmount.W idth = 100
ts2.GridColumnS tyles.Add(csOrd erAmount)

' Add the DataGridTableSt yle instances to
' the GridTableStyles Collection.
myDataGrid.Tabl eStyles.Add(ts1 )
myDataGrid.Tabl eStyles.Add(ts2 )

' Sets the TablesAlreadyAd ded to true so this doesn't happen again.
TablesAlreadyAd ded = true
End Sub

Protected Sub button2_Click(s ender As Object, e As System.EventArg s)
Dim bmGrid As BindingManagerB ase
bmGrid = BindingContext( myDataSet, "Customers" )
MessageBox.Show (("Current BindingManager Position: " & bmGrid.Position ))
End Sub

Private Sub Grid_MouseUp(se nder As Object, e As MouseEventArgs)
' Create a HitTestInfo object using the HitTest method.
' Get the DataGrid by casting sender.
Dim myGrid As DataGrid = CType(sender, DataGrid)
Dim myHitInfo As DataGrid.HitTes tInfo = myGrid.HitTest( e.X, e.Y)
Console.WriteLi ne(myHitInfo)
Console.WriteLi ne(myHitInfo.Ty pe)
Console.WriteLi ne(myHitInfo.Ro w)
Console.WriteLi ne(myHitInfo.Co lumn)
End Sub

' Create a DataSet with two tables and populate it.
Private Sub MakeDataSet()
' Create a DataSet.
myDataSet = New DataSet("myData Set")

' Create two DataTables.
Dim tCust As New DataTable("Cust omers")
Dim tOrders As New DataTable("Orde rs")

' Create two columns, and add them to the first table.
Dim cCustID As New DataColumn("Cus tID", GetType(Integer ))
Dim cCustName As New DataColumn("Cus tName")
Dim cCurrent As New DataColumn("Cur rent", GetType(Boolean ))
tCust.Columns.A dd(cCustID)
tCust.Columns.A dd(cCustName)
tCust.Columns.A dd(cCurrent)

' Create three columns, and add them to the second table.
Dim cID As New DataColumn("Cus tID", GetType(Integer ))
Dim cOrderDate As New DataColumn("ord erDate", GetType(DateTim e))
Dim cOrderAmount As New DataColumn("Ord erAmount", GetType(Decimal ))
tOrders.Columns .Add(cOrderAmou nt)
tOrders.Columns .Add(cID)
tOrders.Columns .Add(cOrderDate )

' Add the tables to the DataSet.
myDataSet.Table s.Add(tCust)
myDataSet.Table s.Add(tOrders)

' Create a DataRelation, and add it to the DataSet.
Dim dr As New DataRelation("c ustToOrders", cCustID, cID)
myDataSet.Relat ions.Add(dr)

' Populates the tables. For each customer and order,
' creates two DataRow variables.
Dim newRow1 As DataRow
Dim newRow2 As DataRow

' Create three customers in the Customers Table.
Dim i As Integer
For i = 1 To 3
newRow1 = tCust.NewRow()
newRow1("custID ") = i
' Add the row to the Customers table.
tCust.Rows.Add( newRow1)
Next i
' Give each customer a distinct name.
tCust.Rows(0)(" custName") = "Customer1"
tCust.Rows(1)(" custName") = "Customer2"
tCust.Rows(2)(" custName") = "Customer3"

' Give the Current column a value.
tCust.Rows(0)(" Current") = True
tCust.Rows(1)(" Current") = True
tCust.Rows(2)(" Current") = False

' For each customer, create five rows in the Orders table.
For i = 1 To 3
Dim j As Integer
For j = 1 To 5
newRow2 = tOrders.NewRow( )
newRow2("CustID ") = i
newRow2("orderD ate") = New DateTime(2001, i, j * 2)
newRow2("OrderA mount") = i * 10 + j * 0.1
' Add the row to the Orders table.
tOrders.Rows.Ad d(newRow2)
Next j
Next i
End Sub
End Class

Nov 21 '05 #1
0 1381

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
6584
by: Nicolas Keller | last post by:
Hi! I'm used to have Mozilla for testing my PHP sites when I'm coding. The site's nearly finished, now I've made a test with the Internet Exlporer... guess what... failed. The problem: I'm using a form that submit's (POST) its data via three different image buttons (depending on which button you click, something different should happen):
3
4341
by: John Dunlop | last post by:
(Note crosspost and follow-ups to ciwah.) Nicolas Keller wrote in thread "Differences in form handling btw Mozilla and IE?": > The problem: I'm using a form that submit's (POST) its data via three > different image buttons (depending on which button you click, > something different should happen): > > <form action="id.php" method="post" name="form2">
7
1517
by: Microsoft | last post by:
I'm trying to use threading for the first time and can't get it to work. (VB) In the page I've got: Sub Page_Load( sender As Object, e As EventArgs ) dim o as new Example.Test o.CreateThread() End Sub
5
3926
by: ortaias | last post by:
I have a form which calls up a second form for purposes of data entry. When closing the data entry form and returning to the main form, things don't work as expected. When I return to the main form, I trigger the on acitvate event to run a macro. I can use the Dlookup function to update my fields, which is OK. However, I intitially tried to use the Repaint Object command to repaint the form. That did not work. Though I solved the...
17
479
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I get the value of a form control? ----------------------------------------------------------------------- In HTML documents, named forms may be referred to as named properties of the « document.forms » collection, and named form controls may be referred to as named properties of the form's elements collection: var frm = document.forms;
18
5440
by: Thomas Lunsford | last post by:
I have inherited a set of asp pages that I now need to augment. In order to minimize changes to production code, I would like to make a "call" to an asp page from a new asp page. Existing code is using many Request.Form variables, and I would very much prefer not to change this code. The new page will retrieve data that I would like to fill into Request.Form variables that are used in the old code. So, is it possible for me to set...
9
18021
by: RvGrah | last post by:
I'm completely new to using background threading, though I have downloaded and run through several samples and understood how they worked. My question is: I have an app whose primary form will almost always lead to the user opening a certain child window that's fairly resource intensive to load. Is it possible to load this form in a backgroundworker and then use the Show method and hide method as necessary? Anyone know of
7
1157
by: Pieter | last post by:
Hi, I have some generic module that handles exceptions. simply you call it like this: "LogManager.ErrorMessage(ex)". Worked great, until we now discovered that it isn't Thread-safe. What actially happens is this: A Form is made, labels and buttons are made etc with the exception-details, but when trying to show the Form (MyExceptionForm.ShowDialog) we get an System.Security.SecurityException (see udnerneath for more info).
7
1955
by: =?Utf-8?B?TWF0dA==?= | last post by:
Hi I have an app that runs without a main form, just a notification icon, when the user clicks the icon the form is shown, and when the form is minimized it's hidden. This all works great, and I have implemented single instance so that when another instance is run, an event gets signalled in the 1st instance, and what I would like to do is to show the form. I can do this using Form.Invoke to show the form in most cases, however at...
0
8676
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8608
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9164
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7734
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6524
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3051
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.