|
Sounds like Panel2 is hidden behind something else, or possibly not even added to the form correctly
|
|
|
|
|
Apparently it didn't work because I had one panel over the other.
But that is the entire point of this.
Instead of putting a ton of controls next to each other or in TapControls, I want them to appear and disappear at the same location.
How do I do that?
|
|
|
|
|
Megidolaon wrote: Apparently it didn't work because I had one panel over the other.
It's not that at all. Let me run through the sequence of events you went through to construct this:
1) create two panels, one above the other. (could be side by side, I dunno).
2) Put controls on each panel.
3) Drag one panel over the other so they are in the same place.
Now, when you make one visible and one invisible, you see one panel.
When you make that panel invisibile, and the other visible, you see no panels.
This is because when you dragged one panel onto the other it became a child of the panel you dropped it on. So when you make the master panel invisible, you hide all it's children - including the other panel.
Leave them separate, and move them with your code in the form load event. It'll work now...
Or better, use a TabControl instead of panels...it is a lot easier to maintain in the designer!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
as Griff said, you probably have one of the panels containing the other.
There are many ways not to do that, here is one I use sometimes:
- inside Visual Designer, add first panel, smaller than intended;
- now add second panel next to the first one, also smaller than intended;
- so far you made sure they both belong to the Form directly;
- now select one, look for the Properties pane, and adjust the Location and Size properties by editing the numbers (watch the result each time you leave the property's value field);
- then select the second one (if not visible, since overlapped by the other one, use the combobox in the properties pane), and give it the appropriate (maybe the same) values for Location and Size.
The net result is you only see one of the panels in Designer, however you will see one or the other at run-time.
|
|
|
|
|
Thanks.
I didn't notice I had made panel2 the child of panel1 cause a single mm off and they were still independent.
But changing locations works great. In the Visual Designer I have the panels next to each other and just overlay them at runtime like this:
panel2.Location = new Point(panel1.Location.X, panel1.Location.Y);
I still need to test how this works with the many different controls needed on other forms.
After all the point of this is to switch from a huge cluster**** of nested tab controls to a more intuitive and easier usable design like for example VS options.
|
|
|
|
|
If the Form is going to show mostly text, I tend to create the structured parts by run-time code, i.e. code I write myself, as opposed to me doing repetitive sequences of point-and-click operations inside Visual Designer.
You could easily write a method that adds a Panel holding some TextBoxes/ListBoxes/TreeViews/whatever, positioning them, setting their Anchors/Docks, etc. Then call that method over and over.
Some advantages: it becomes easier to change your mind about layout details; and you could fetch the data from some external store (file, database, ...) and make it much more dynamic.
|
|
|
|
|
Nah, it's not that much to do.
But I tested it now with a form that has many controls for data input and it works like a charm.
In the designer it's a huge form with all panels side by side for easy editing and the first thing I do when the form is constructed is change the size and hide all panels.
Then I display the appropriate panel when selecting a node and hide all others.
|
|
|
|
|
Hi
i have created a media player i have problem in making 10 band equalizer using DirectX 9.0 in C# .net and also have a doubt that how to play .MP4 files.
I will be thankful if i get the solution.
Thank you,
NISHAd
|
|
|
|
|
Solution to what? You haven't asked a question. Where exactly are you getting stuck? Describe the circumstances and what the problem is. Just saying "I have a problem with ..." doesn't tell us anything we can use to solve the problem.
|
|
|
|
|
Maybe this[^] article will help.
Commercial product.
/ravi
|
|
|
|
|
Hi this is my code and it works fine when the XML document have a proper opening and Closing tag
XmlDocument objxmlDoc = new XmlDocument();
objxmlDoc.Load(txtFileName.Text);
Here txtFileName.Text refers to the physical path of the XML file
I am doing this to change the attributes of XML doc programatically .The above code snippet works fine for a proper XML doc.But it throws an exception for improper XML doc which misses closing tag. I need a code snippet/ suggestion to change the attribute of the XML doc even if it is invalid (missing close tags).
Thank u
Raghav
modified on Thursday, September 9, 2010 5:40 AM
|
|
|
|
|
I think your question needs some clarification:
1. You have a non-valid XML document
2. You want to apply styles (whatever that means)
3. You want to use a C# winform
Please explain the connection between these three.
It's time for a new signature.
|
|
|
|
|
Hi this is my code and it works fine when the XML document have a proper opening and Closing tag
XmlDocument objxmlDoc = new XmlDocument();
objxmlDoc.Load(txtFileName.Text);
Here txtFileName.Text refers to the physical path of the XML file
I am doing this to change the attributes of XML doc programatically .The above code snippet works fine for a proper XML doc.But it throws an exception for improper XML doc which misses closing tag. I need a code snippet/ suggestion to change the attribute of the XML doc even if it is invalid (missing close tags).
Thank u
|
|
|
|
|
raghavsesh wrote: XML Document with missing closing tags
No you don't.
|
|
|
|
|
Let's call it an XM Document, OK?
|
|
|
|
|
|
as long as it moves in style, as that is what the OP asked for.
|
|
|
|
|
Hi this is my code and it works fine when the XML document have a proper opening and Closing tag
XmlDocument objxmlDoc = new XmlDocument();
objxmlDoc.Load(txtFileName.Text);
Here txtFileName.Text refers to the physical path of the XML file
I am doing this to change the attributes of XML doc programatically .The above code snippet works fine for a proper XML doc.But it throws an exception for improper XML doc which misses closing tag. I need a code snippet/ suggestion to change the attribute of the XML doc even if it is invalid (missing close tags).
Thank u
|
|
|
|
|
The Xml classes are designed to work with properly formatted XML documents. If it's not well formed then you are going to have to roll your own parsing functionality to cope with this - as the document is no longer XML, it's just fancily formatted text.
|
|
|
|
|
Hey Raghav,
you're likely to have loads more issues down the line if the XML isn't correctly formatted, since most functionality will assume a valid document to avoid unexpected side effects.
A nasty hack around would be to try the Load method, then if that fails because of invalid XML, have some code called from the catch to open the document via a text reader and do a string replace on the tag name (e.g. string output = input.Replace("<mytag", "<mytag attribute='1'");). Other, better hacks also exist, but get pretty complex for something which is ultimately wrong though.
The better path is to throw an exception asking for a valid input / logging the bad data so that it can be fixed. The other option's to write code which attempts to work out what's wrong with the data and correct it automatically; though that's going to be complicated & could produce unexpected results.
If you can provide more information on what you're attempting (e.g. why is the XML invalid in the first place, is your app a service, or will there be a user interface allowing the user to see and correct exceptions, etc, the guys on here may be able to assist in recommending a better strategy.
Hope something in that lot helps.
JB
|
|
|
|
|
Hello,
I have been struggling with some threading issues over the last couple of days. I am getting close to getting this thing to work but there are still a few niggles.
So, I have a thread that is called as follows and after the thread starts, my application shows a modal dialog box. So far so good:
t = new System.Threading.Thread
(delegate()
{
result = Init();
});
t.Start();
dialog.ShowDialog();
This works fine and there are no problems. Now, the user can hide this dialog box and when that happens the subsequent code gets executed as expected and this is not a problem. Also, I use ShowDialog(), so hiding or calling Close() should not call dispose as indicated in the docs.
Also, the dialog box is a singleton and lives for the duration of the application.
Now, my dialog box has a progress bar which gets updated by the calling thread and the update method that gets executed is as follows:
delegate void ProgressValueDelegate(int value);
public void SetProgressValue(int value)
{
if (this.InvokeRequired)
{
ProgressValueDelegate pvd = new ProgressValueDelegate(SetProgressValue);
this.Invoke(pvd, new object[] { value });
}
else
{
m_progressBar.Value = value;
}
}
So, as soon as the dialog box is hidden, the subsequent call crashes at the Invoke() call. I think there is some race condition going on somewhere because in the debugger the InvoleRequired value is fasle. However, the code has already entered the 'if' condition.
Does anyone know how I can handle this sort of situation?
Thanks,
Keith
|
|
|
|
|
Object Disposed exception has nothing to do with Invoke Required. I would suggest checking to see if the progress bar has been disposed before assigning its value.
|
|
|
|
|
Thanks for your reply. I did check all that and the IsDisposed property is false.
Here is the call stack
Object name: ProgressForm'.
at System.Windows.Forms.Control.MarshaledInvoke(Control caller, Delegate method, Object[] args, Boolean synchronous)
at System.Windows.Forms.Control.Invoke(Delegate method, Object[] args)
at ProgressForm.SetProgressDescription(String description)
at Mycomponent.UpdateProgressDialogDescription(String description)
at Mycomponent.Initialize(Int32 hashCode, Int32 numSeries, Int32[] nInstances)
at
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()</ExceptionString></Exception></TraceRecord>
An unhandled exception of type 'System.ObjectDisposedException' occurred in System.Windows.Forms.dll
<pre>
Cheers,
Keith
|
|
|
|
|
at ProgressForm.SetProgressDescription(String description)
It appears to be calling SetProgressDescription and not SetProgressValue that you have included previously. Is this the issue?
WarePhreak
Programmers are tools to convert caffiene to code.
|
|
|
|
|
Your code should read:
if (this.InvokeRequired)
{
ProgressValueDelegate pvd = new ProgressValueDelegate(SetProgressValue);
this.Invoke(pvd, new object[] { value });
return;
}
else
{
m_progressBar.Value = value;
}
I usually check to see if ISyncronizeInvoke is implemented and work on interface. This is how it would look:
ISyncronizeInvoke sync = (ISyncronizeInvoke)this;
if (sync != null)
{
if(sync.InvokeRequired)
{
ProgressValueDelegate pvd = new ProgressValueDelegate(SetProgressValue);
object[] args = { value };
sync.Invoke(pvd, args);
return;
}
else
{
m_progressBar.Value = value;
}
}
|
|
|
|