|
If you are talking about ToolStripContainer and ToolStripPanel: use the "BottomToolStripPanelVisible" (etc.) property of the container control.
|
|
|
|
|
oops!
yes ToolStripPanel, but I still have the same problem.
The BottomToolStripPanelVisible Property let me see the ToolStripPanel but at design time I see it with a little button with a arrow which let me expand and collapse it, at runtime the little (thin) button is not there anymore. I'd like to expand/collapse it at runtime to show or hide the controls in it.
thanks a lot!
F2R
|
|
|
|
|
Hi
I am a beginning VB.Net programmer and I am looking to create an application for both single machine as well as multiple machines over a network. Is there anything that needs to be changed in the initial set-up of the application ?
Forgive me if this is a simple answer.
|
|
|
|
|
It's a question that's impossible to answer because we know absolutely nothing of the application your trying to write. There is no "one thing" to change in any configuration file to magically make your application "network aware". You have to write your app to be network aware yourself...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
In previously posted messsage I asked how to detect controls I create by using for example New Panel and so on, and the answer was that all controls are stacked into a container/list called controls in Me.Controls(index).
But the thing now is that I want to delete/clear those newly created controls...so I can keep track of the index much better. I know there's a Me.Controls.Clear() but that kills all controls.
Is there a way to get around this?
Best Regards,
Hmmkk
|
|
|
|
|
The same way you referenced the control before. Just call it's Dispose method.
It might look something like this, your code will, of course, look different:
CType(Me.Controls(index), Control).Dispose()
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
This is the code for the disposing:
Dim a As String<br />
For i As Integer = 1 To 10<br />
a = "pnlThing" & i<br />
For j As Integer = 0 To Me.Controls.Count - 1<br />
If Me.Controls(j).Name = a Then<br />
'Me.Controls(j).Dispose()<br />
CType(Me.Controls(j), Control).Dispose()<br />
<br />
End If<br />
Next j<br />
Next i
But this gives me ArgumentOutOfRangeException error=/ and the program crashes.
How to rewrite this code so that it will run throught all controls and kill those for who the text applies?
Regards,
Hmmkk
|
|
|
|
|
Looping through 10 different names, and the controls for each name, is very slow. I would suggest naming your panel controls that are removable with a common name prefix and a number and just going through the controls array once. It looks like you already have something like this, but just to be sure...
But, you're getting the IndeoxOutORangeException because when you Dispose the control, the number on controls in the collection is reduced by one, making the top end of your loop greater than the new number of controls in the Control array. The solution is deceptively easy -- Start and the end of the array and work your way back!
For i As Integer = Me.Controls.Count - 1 To 0 Step -1
If Me.Controls(i).Name.StartsWith("pnlThing") Then
Me.Controls(i).Dispose()
End If
Next
Note, you cannot use a For Each enumeration in this loop because of the same problem! Modifying the size of a collection during an enumeration is, in most cases, not allowed!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-- modified at 11:02 Wednesday 28th December, 2005
|
|
|
|
|
Hmm Yeah, well I tested reversing the loop (For i As Integer = Me.Controls.Count - 1 To 0) But then nothing happend... but with your code it works...
Dim a As String
For i As Integer = 1 To 10
a = "pnlThing" & i
For j As Integer = Me.Controls.Count - 1 To 0
If Me.Controls(j).Name = a Then
Me.Controls(j).Dispose()
End If
Next j
Next i
How come this doesnt work? Ooh, nm it was the Step -1 that had to be there=S
Awell, can be good for the record to let this be said...
But well I guess you have solved my current problem so Thanks alot but how exactly did you mean that the array you were talking about would look like?
(Looping through 10 different names, and the controls for each name, is very slow. I would suggest naming your panel controls that are removable with a common name prefix and a number and just going through the controls array once. It looks like you already have something like this, but just to be sure...)
Best Regards,
Hmmkk
-- modified at 11:16 Wednesday 28th December, 2005
|
|
|
|
|
Hmmkk wrote: But well I guess you have solved my current problem so Thanks alot but how exactly did you mean that the array you were talking about would look like?
I don't have a clue what your getting at here...
Controls() is an array, or Collection, of, well, Control objects. If you have 10 panel controls on your form, there will be 10 Panel controls in the Controls collection, at index positions 0 through 9. Controls.Count will return 10.
Now, you setup your loop to hit every index in the Controls collection, 0 through 9, using:
For j As Integer = 0 To Me.Controls.Count - 1
This will setup the loop to increment j from 0 to 9. Once it's setup, there's no changing the limits of the loop.
Next, you eventually find your first panel control and Dispose it. Now, without executing any other statements, what do you think Controls.Count is going to return? It's not 10 anymore, it's 9. The new VALID index values are now 0 through 8, not 9. But your loop is going to run until j reaches 9... See what the problem is?
Now, to your OTHER loop. The one that is putting together panel control names.
For i As Integer = 1 To 10
a = "pnlThing" & i
.
.
.
Next
You're creating 10 names for panel controls, one at a time. When the first panel control name is built, you execute another loop to go through ALL the controls on the form, looking for the ONE control with this name. If there are 100 controls on the form, and your looking for 10 names, your actually looking at the names of 1,000 controls! Why??????
If you name your deletable panel controls with a unique name prefix, you can skip looking for 10 different control names that match each one of these names exactly and just search the Controls collection ONCE (100 controls in this example), and look for names that START WITH the name you're using to name DELETABLE controls. Like...
For i As Integer = Me.Controls.Count - 1 To 0 Step -1
If Me.Controls(i).Name.StartsWith("DeletablePanel") Then
Me.Controls(i).Dispose()
End If
Next
Of course, your panel controls will have to be created with the names DeletablePanel1 , DeletablePanel2 , DeletablePanel3 , DeletablePanel4 , ...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Yes, I kind of figured out what you meant and you have a point indeed with the loops, and I thoought of that too. But the thing is that I need to have these controlable individually...The program I'm making is a Memory Boosting program (for your brain that is), where one exercise is to remember sequences of flashing panels and then recalling this sequence by clicking at them in the right order.
So to detect this mouseclick I either have to get the coordinates and make my own detectionsystem which might get tricky? Or I need to implement a dynamical Panel_Click handeler that handels every panel that is created by these lines of code? Also I need an array containing the right order/answer, which can come with a few problems too when it comes to comparing...?
How am I suppose to detect which "pnlThing" it is if not looping through the whole array?
(But btw the .StartsWith is really speeding things up and is very nice.)
Regards,
Hmmkk
-- modified at 15:57 Wednesday 28th December, 2005
|
|
|
|
|
It sounds as though you shouldn't be creating and deleting the panels. Rather just altering what they're displaying. Creating and killing controls at runtime is a very expensive operation.
Just keep track of the Panels in your own array and modify their properties. Instead of killing the panel, couldn't you just set it's Visible property to False?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Well yeah I have thought about taking it to a more "stationary system"... but I don't really want to mess up the layout(in the designer), everthing will become stacked and impossible to find, that was one of the reason to do it at runtime.
Also as I said... it's about sequences and just using a timer to flash a panel at a time, but with this is also 3 different difficulties, which contains of more and more panels, at most 5 x 6 panels. That would be like 30 * 30 loops == 900 loops, which might not be very efficient no=/ But if I go for the stationary with allready placed panels... I guess I would have a limited amount of panels to handle and therefore could handle them all in one single handler. But isn't there away to handle all those created controls? ( I guess there is one for ALL controls, but I do have buttons and radio buttons that need special treatment, so what about a range of controls?)
Thanks alot for help so far.
Regards,
Hmmkk
|
|
|
|
|
Like I said, you'll have to track them yourself in your own collections. They'll also have to be added to the Form's Controls collection so you can actually see them.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi folks,
I need (a Tool or a Hint) to convert programmatically a webpage (URL) to a thumbnail,
even using Internet Explorer as a parsing unit.
There's many tools over the Internet, but i figure out that it can be possible
using the GDI+ API's in the .net Framework.
Nobody knows how to perform this task?
Thanks i.a. to all that read this topic.
Ennio Della Lucia
Italy
|
|
|
|
|
This is done in VB6.0
I have closed the application, the workbook and quited the excel application but the excel is still in memory.
Actually i have some macros in my excel .It might be creating the problem,i guess now.
and from one site i have seen that i have to ensure whether the excel has been saved or not (I am giving book.save in the code)
for that i did
while (not workbook1.Saved)
DoEvents
wend
But it didnt work...then,
I closed each and every workbooks by putting it in a loop.
But still excel remains in memory .I could open only if i have closed the excel.exe from the taskbar.Please help...
Thanks
|
|
|
|
|
can anybody tell me how i can communicate with the hardware through serial port in VB.NET.
Kusum
|
|
|
|
|
What you send over the serial port will be VERY device specific.
How you send it will depend on the version of the .NET Framework you're using.
For .NET 1.0 and 1.1, you'll have to find a 3rd party Serial Port library (unless you want to write your own). I suggest searching GotDotNet.com for "serial port" to find one.
For .NET 2.0, you can use the SerialPort[^] class.
I don't have any examples for either of them. You'll have to do some Googling yourself.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
Hi!
Trying to get the handle of the window (actual app, not textbox or other window) that was active before I clicked in my own win form? I've tried GetActiveWindow and GetWindow with the GW_HWNDNEXT and GW_HWNDPREV paremeters but I'm no expert using Windows API's and can't seem to get it to work:
'Get the next window handle.
Dim vWndActive As IntPtr = GetActiveWindow
Dim vWndPrev As IntPtr = GetWindow(vWndActive, GW_HWNDPREV) 'this line doesn't work!!
'Activate previously active window
Dim vClassName As String = Space(256)
GetWindowText(vWndPrev, vClassName, vClassName.Length)
AppActivate(vClassName)
I know this code doesn't work and may not make much sense but it's the stripped version of what I'm trying to do and I think you get the point.
(Ps. Using vb.net)
|
|
|
|
|
There is no function that will return the previously active window. AFAIK, the only reliable way would be to override your window's WndProc and look for the WM_ACTIVATE message. If the low order word of the wParam field of this message contains the WA_ACTIVE or WA_CLICKACTIVE message, the lParam of the message will contain the handle to the window that lost the focus.
Once this message is processed by your application, it's way too late to call any function to find out what the previous window was.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
What are the list of events that get fired during the life cycle of a Win Form in .NET, I mean when it is created and destroyed.
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
After a quick search on MSDN for "forms order of events", click[^].
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thats for Visual Studio 2005. Is it the same for Winforms in Visual Studio 2003?
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
No, that's for Windows Forms in .NET. VB.NET 2005 added the little note in the middle of the page, but the order of events has not changed in the Form class since .NET 1.0 was released.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|