|
Its a separate class, included jst for backward compatibility to VB6 developers.
|
|
|
|
|
Hello everyone,
I am really new with Visual Basic .NET 2003 and have come across a problem that I cannot seem to figure out. I have spent a lot of time reading in books and articles to figure this out, and because it is such a simple problem - it is quite frustrating.
I am making a Tic Tac Toe game to get more familiar with VB. I have already finished a very simple Tic Tac Toe program and now am moving into an advanced version with multiple forms. Each form acts like the next screen within the game - so, I wanted to make it so that the forms would hide and show themselves in the same area as the last screen. Also, at the bottom of the screen - the task bar resets every time a form is loaded.
Any information on how to manage multiple forms to act as if they are only one form would be great. Articles, Links, Examples, anything you can spare.
My current way for showing and hiding a form is:
dim testform as new testform
testfor.show()
I am using key words Show, Close, and Hide. Well, anything would be helpful. Thanks!
~Achithyn
|
|
|
|
|
A suggestion. How about using an MDI application, and letting your forms be a children within the parent?
"if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler.
|
|
|
|
|
I will look into MDI forms and see what happens ) Thank you for the prompt reply! If there is anything else that may be able to help me make this little program of mine, feel free to share. Thanks again - I will see what happens and, depending, post back here.
~Achithyn
|
|
|
|
|
No Prob. I too, once tried to make a tic tac toe program. It wasn't too good, but it was fun.
Good luck with your app.
"if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler.
|
|
|
|
|
I have been doing whatever I can to learn what I can do to fix this small problem. I happen to be quite the perfectionist. I think that can be both a good thing and bad thing. Well, I looked more into what MDI is and what it is used for and this is what I got:
Quote from MSDN
----Multiple-document interface (MDI) applications allow you to display multiple documents at the same time, with each document displayed in its own window. MDI applications often have a Window menu item with submenus for switching between windows or documents.
Also, when you change the form you wish to be the MDI Parent, it changes the color to a gray. I found another snippet from MSDN that said:
Quote from MSDN
----Additionally, be aware that the edge of the MDI parent form will pick up the system color (set in the Windows System control panel), rather than the back color you set using the Control.BackColor property.
I do not understand where I can edit the Windows System Control Panel. Another thing with MDI is said it is best to use with a maximized screen rather than a small version of the screen.
I was told that I may want to check in with Modal and see if that would help, though I do not know what that is. Once again, anything would help - thanks for the time!
~Achithyn
|
|
|
|
|
Hmmm...let's see how to explain MDI Applications.
Take for example MS Word. Word can have several documents open inside one parent. When you close all the word document, what you see is basically a word with only toolbars and a gray background. That's how a parent form looks like without a child. And all the documents in words are the child forms. you can resize, minimize, maximize, etc.
I'm probably not explaining it too well.
"if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler.
|
|
|
|
|
The problem doesn't lend itself to being a multiple app form. Are you saying that your closing each form after a move is made and showing the next form to display the results and waiting for the next move? Walking from form to form in a game is not a good idea because each copy of the form will hold a reference to the next form, thereby keeping ALL of them open and running. When the last form is done, each form leading up to that one must close in the reverse order that they were launched in order to properly release its resources. All your oding with this method is taking up more and more memory the farther into the game to get.
You can't close your first form, you can hide it though, because the is the form that has your main message pump behind it. Once that pump is ended, your entire app closes, not just that form.
A better multiple app version of the game would be to display the board in one window and the game status and, possibly, the computers thinking in another form. This way you only have 2 forms to manage and it better represents a real world application.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
The reason I have several forms, is to collect information from the player and pass it on to the next form. The actual game play is all done within one form. This is how it is built for Player Vs. Player:
--Form1 (frmMenu) is the first Game Menu that loads when you start the game.
--Form2 (frmSettings) is the form that loads when you click on "Vs. Player" button. This form allows the member to choose their name, mark type (you can change the normal "X" to a 3 character mark, such as initials) and color.
--Form3 (frmGame) is the actual game that loads when you continue from Form2. This Form holds all the information for the game and allows you to play. This form will be changed depending upon settings you set in Form2 - or if you play Vs. Computer - or take the adventure mode.
You see, the actual game is not laid out to work in several forms, the multiple forms are simply there to retrieve data for the actual game.
I have been thinking more and more on MDI - and now I think I know how it works and how it will work on this game. The main screen will be the parent, and then frmMenu, frmSettings, frmGame and any other form that I make later on will be the child form to this parent so that all will be organized and within the parent. I know why the backcolor changes to gray now, and know how to go around that problem.
I will not close the forms that load, rather use the Hide() command instead. As for the main form, you can close it if you want by using dim frmMenu as new frmMenu and Show() within the form load code bit. I don't know how bad or good that is with the program, just know that it works... lol.
Well, thanks for the help guys, I will see what happens.
~Achithyn
|
|
|
|
|
Sorry. Your first post made it sound like you were launching a new form with each step in the game, not an options form.
You can't close the main form that was launched when your app started. You can HIDE it, but closing it will result in your app closing.
You might want to check this[^] out to clear up any grey areas concerning multiple forms and passing data.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Awesome, thank you for the information. I will check out the MSDN chapter to this and see what else I learn.
~Achithyn
|
|
|
|
|
I am working in VB.Net Express with the 2.0 framework and am having touble getting the new DataGridView to populate with a DataSet. I use it the same way I do the datagrid but nothing happens. I do not get any errors nor does the grid populate. Documentation says DataGridView can populate from a dataSet
DATASET.READXML(FILE.XML, XMLREADMODE.AUTO)<br />
DATAGRIDVIEW.DATASOURCE = DATASET
Has anyone worked with this yet?
|
|
|
|
|
I want to add a column radio button in the datagrid. Is possible to do this? does someone know some scources to learn datagird? I need to deal with datagrid a lot, but I'm pretty new in datagrid, is any ways to learn faster? thanks for all your help!
Lisa
|
|
|
|
|
Well, I always find Windows Forms FAQ[^] a good place to start.
As for radio button columns, there's an section on how to make combobox buttons. I suppose you could modify the code so that it shows radio buttons instead.
"if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler.
|
|
|
|
|
thanks Michael..that's a very good website..can I ask you one more question? I can't fully understand their code, what can I do? I download their code, and it runs in their app. If I copy their code to my app, then it can't run in my code. I don't know how to fix it. Thanks!
Lisa
|
|
|
|
|
Lisana wrote:
thanks Michael
Who? Oh, that last part there is a sig. I was quoting Michael, but I'm not Michael.
Well, my suggestion is to try and understand it, and then modify the code. The code snippet there is usually well commented, and you could always google for parts you don't understand. Copy and paste usually doesn't work as intended
"if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler.
|
|
|
|
|
I'm sorry to get your name wrong..
Thanks Nick!
Lisa
|
|
|
|
|
Hi,
i'm trying to write a little telnet client in vb.net and I'm going crasy with it.
here is the main code :
Private Function sendReceiveTCP(ByVal message As String) As String<br />
Try<br />
' Translate the passed message into ASCII and store it as a Byte array.<br />
Dim data As [Byte]() = System.Text.Encoding.ASCII.GetBytes(message)<br />
<br />
' Get a client stream for reading and writing.<br />
' Stream stream = client.GetStream();<br />
Dim stream As System.net.Sockets.NetworkStream = msocket.GetStream()<br />
<br />
' Send the message to the connected TcpServer. <br />
stream.Write(data, 0, data.Length)<br />
<br />
Console.WriteLine("Sent: {0}", message)<br />
<br />
' Receive the TcpServer.response.<br />
' Buffer to store the response bytes.<br />
data = New [Byte](100000) {}<br />
<br />
' String to store the response ASCII representation.<br />
Dim responseData As [String] = [String].Empty<br />
<br />
' Read the first batch of the TcpServer response bytes.<br />
Dim bytes As Int64 = stream.Read(data, 0, data.Length)<br />
responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes)<br />
Console.WriteLine("Received: {0}", responseData)<br />
<br />
Return responseData<br />
Catch ex As ArgumentNullException<br />
Console.WriteLine("ArgumentNullException: {0}", ex)<br />
Catch ex As System.Net.Sockets.SocketException<br />
Console.WriteLine("SocketException: {0}", ex)<br />
End Try<br />
End Function<br />
Juste before call this method, I open the socket like this
msocket = New System.Net.Sockets.TcpClient(servername, port)
Then I send some data to it like this
Me.sendReceiveTCP("login myuser")
And the problem come now when I try to send the second data with the following code :
Me.sendReceiveTCP("pass *******")
When debugging step by step, I can notice that the problem occurs on
<br />
Dim bytes As Int64 = stream.Read(data, 0, data.Length)<br />
The program hang and the only thing to do is to stop it.
Any1 know where I'm wrong ?
thx
Sybux
|
|
|
|
|
Your Read code is is blocking call. If there is no data to read, the .Read method will block further execution until data is available. You should check to see if there is data to read by checking the streams DataAvailable property. The following example should give you an idea: (Also, the .Read method will return an Integer, not an Int64...)
Dim myReadBuffer(1024) As Byte
Dim myCompleteMessage As String = ""
Dim numberOfBytesRead As Integer = 0
' You could add code to this loop to wait a certain number of seconds before timing out.
Do While Not myNetworkStream.DataAvailable
Application.DoEvents()
Loop
' Incoming message may be larger than the buffer size.
Do
numberOfBytesRead = myNetworkStream.Read(myReadBuffer, 0, myReadBuffer.Length)
myCompleteMessage = [String].Concat(myCompleteMessage, Encoding.ASCII.GetString(myReadBuffer, 0, numberOfBytesRead))
Loop While myNetworkStream.DataAvailable
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I've corrected my code with yours and I still got problem.
The change your code made is that now the program dosen't hang. When I send my second sendReceiveTCP, the code loop on the
<br />
Do While Not myNetworkStream.DataAvailable<br />
Application.DoEvents()<br />
Loop<br />
and suddenly it goes out of the sub, even the calling sub so that I never receive answer from my TCP Server.
|
|
|
|
|
I am trying to only submit the certain rows from the dataTable that have been modifed with 2 ways to which both of them result in all the rows being submitted.
The first way is using the GetChanged method of the dataTable, and it returns all the rows. The second way is using the if myRow.RowState = DataRowState.Modified, and it says they were all modified.
I tried to insert this before the fill operation:
.AcceptChangesDuringFill = True
after having problems, assuming that it was during the fill that the rowState was set to modifed, but no luck.
I have also tried after inserting the data into the table:
myTable.AcceptChanges.
I am pretty sure that nothing else touches the rows after that so they should not get there rowStatus changed.
If anyone can see what I am doing wrong, or leaving out I would appreciate the help.
Thanks
|
|
|
|
|
It seems that you are doing something wrong in your code. I have just tried that on my computer and GetChanges() is working just fine.
I tried something like this
Me.DataGrid1.DataSource = Me.Dataset11.authors.GetChanges(DataRowState.Modified)
and the GetChanges() returned only the rows that I modified
Give me some more of your code if you like and I might find the solution.
Better luck next time
sony speed
|
|
|
|
|
thanks for the help.
What seemed to be the problem was that initially I didn't have the acceptChanges() in there and after I inserted it I forgot that I had another method that was stipping out all the null values and that was making chnages once again. All is gooood now.
|
|
|
|
|
I am having a hard time getting the getChanges to retrieve the changes that were performed on the last row of the data. Since the user is not able to create rows, nothing really happens when the hit the enter key on the last line. I suppose I could always have an extra blank row at the bottom of the grid, but is there a better way to deal with this?
|
|
|
|
|
Hi,
I have created a form to be used by a user. On the form, the user may add one or more controls (textboxes). I would like the user to be able to resize these textboxes using the MOUSE.
I was wondering if anyone has an idea on how to do that or if it is possible?
The idea is similar to the way we are able to resize the control during our design time, which is vb.net's runtime.
Thanks!!
Any suggestions at all will be greatly appreciated...!!
RedDragon
|
|
|
|
|