|
Hi,
I'm building an app in C#. It's a Windows App and it needs this common functionality ( we probably get to see in many windows apps ) where the user can keep on pressing the "Next" button when he finished entering a certain amount of data to go to the next level / display different controls.
The situation Im trying to explain is similar to a Setup program that executes an installation, while you keep on pressing the "Next" button.
So how can i achieve this in C# ? I know that in Java there are several Layout Managers like Card Layout to handle this type of situations. The only way possible I think is to add all the controls to be displayed in each step to a collection of Panels and then toggle their visibilty as needed.
But isnt there any easier way like in Java to get the job done ?
Thanx in advance !
|
|
|
|
|
If you want to show a whole lot of different screens, then I don't see a simpler way of doing it than creating panels as seperate user controls, then adding them all to your form. I'd put the page names into an array, the pages into a hash table by name, and add methods for go forward and backwards that look up the right panel to make visible, if you call an internal method that's a lot easier than trying to hide all panels but one in a lot of different places.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
www.codeproject.com/cs/miscctrl/magicwizard.asp
The Magic tool kit has a fairly easy to use wizard you might want to look at....
|
|
|
|
|
You should post this as a response to the original poster, so he gets an email notification of it.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
www.codeproject.com/cs/miscctrl/magicwizard.asp
The Magic tool kit has a fairly easy to use wizard you might want to look at....
|
|
|
|
|
Thank you very much guys !
I looked up the Magic Wizard code project. I think thats more inline with my requirement. I actually do not hav the time to go thru it now, but when i get back home Ill take a look at it and say how well it suits my purpose, as well as .NET's work around for such a situation.
And also, it jus struck me that my original solution ( the panel collection ) is not that feasible, cos it would take up some memory overhead wudn't it ?
Thanx again guys , sorry for this late and hasty response.
|
|
|
|
|
Can someone please help me with creating a loop to read from an Xml file into a jagged array.
The Xml file looks like this:
<test>
<problem type = "multichoice" elnumber = 8>
<question ID = 1>This is the question text</question>
<answer1>this is answer A</answer1>
<answer2>this is answer B</answer2>
<answer3>this is answer C</answer3>
<correct>answer2</correct>
<explanation>this is why</explanation>
</problem>
<problem type = "dragndrop" elnumber = 4>
<question ID = 2>This is the question text</question>
<explanation>this is why</explanation>
</problem>
Im using a jagged array because each question will have a different number of elements as shown above.
Can anyone suggest a good way to tackle this? An example code or structure would be appreciated. Thanks.
|
|
|
|
|
Just select all root nodes for questions, then for each one, iterate through the subnodes using a for...each, or another xpath if you just want the questions, and then build each array that way.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Ok, thanks I'll try that.
|
|
|
|
|
I assume im to use the XmlDocument Class as opposed to the XmlTextReader class.
I can select the root nodes by using:
XmlNodeList rootList = doc.GetElementsByTagName("problem");
foreach(XmlNode node in rootList)
....
How do I go about retrieving the child nodes? Do i use another XmlNodeList for the child nodes and then build the array within this loop?
Sorry Im new to reading Xml files and was using XmlTextReader initially.
I searched all over for documentation on how to read a Xml document into an array. But I can't find any examples that are similar to what I want to achieve. Any chance you could give me some example code??
Thanks.
|
|
|
|
|
It's a shame you're using Access, as SQL Server or MSDE would just generate XML for you.
foreach(XmlNode node in doc.SelectNodes(@"//problem"))<br />
{<br />
foreach(XmlNode subNode in node.ChildNodes) <br />
{<br />
}<br />
}
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I'd like to write an Internet cafe program which has Address filter function. I want it like this: when user type something in the address bar of Internet Explorer window and press enter, the entered string will be sent to my program prior to IE itself, so I can manage bad addresses. What should I do?
|
|
|
|
|
|
I seriously doubt anyone is going to install software on their machine just to use your Internet Cafe. Your better bet is to use a firewall that already does this for you. What do you think corporations use?
On top of that, you've got a nightmare of a job trying to figure out what a "good" address is and what a "bad" one is.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Greetings,
I am using the PlaySound methode as specified below.
However, It always defaults to the default windows sound
regardless of where I place the file and the path I specify.
Here's the code snippit:
ussing System.Runtime.InteropServices;
namespace MySound {
public class Sound {
[DllImport("winmm.dll")]
public static extern bool PlaySound(string filename,long hmodule, int dword );
// To play the sound, I use:
Sound.PlaySound("BorderLine.wav",0,0x0001|0x0002|0x00020000);
Thanks,
--
Magela
|
|
|
|
|
This site has good info on working out proper pinvoke calls, and the URL is to the page on PlaySound.
http://www.pinvoke.net/default.aspx/winmm/PlaySound.html[^]
Also, is BorderLine.wav in the same folder as your exe ? Have you tried a full path ? Either way, there is another problem, as 2 is the flag to not play the default sound.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Your problem is that the second parameter should be declared as an IntPtr , which is a 32-bit integer in 32-bit Windows and a 64-bit integer under 64-bit Windows (not under the WOW64 subsystem). This is the size of a pointer, which an HMODULE (in the native declaration) is.
A long (System.Int64 ) is always 64 bits. So, unless this only runs on 64-bit Windows as a 64-bit application (support for which starts in .NET 2.0 when compiled with the right flags) your parameters are pushed onto the stack (or into registers, since .NET uses FastCall by default) incorrectly. The third parameter would always be zero because the low-order bits would not be read by the callee (PlaySound ).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Good day all.
I have a two column Listview. The first column I would like to make readonly (I do not want the user to make changes to the content). The second column (Listviewitem sub) I would like the user to be able to make modification to it contents. Has anyone experienced or have written code to handle this type of solution.
Thank you in advance for you assistance.
|
|
|
|
|
That is not the best solution ,but it's easier,You can make your control a data grid,an make teh row read only and the other not,it will be likely for you.
|
|
|
|
|
My advise is that you look into Property Grid. Just do a search here in codeproject for "Property Grid" and you will find plenty of good examples. However; if you insist on using ListView, you will probably have to override the OnPaint event and place a textbox on top of the text you need to edit.
|
|
|
|
|
You might want to take a look at this article[^]
Regards,
mav
|
|
|
|
|
Hey Mav thanks. This is exactly the functionality that I am seeking since I can not find any documentation on editing a subitem other that setting the FullRollSelect property of the ListView.
You have done a great job with the extension of the ListView.
|
|
|
|
|
I recently discovered code for extending the RichTextBox to allow for a Background color on a selection, which is exactly what I neeed. However I am having some problems dealing with the Select/Selection properties. It seems that as soon as I append text to the RichTextBox the entire thing inherits the colors of the last SelectionBackColor given. Here is some sample code:
public class ExtendedRichTextBox : RichTextBox<br />
{<br />
#region Fields<br />
private const int EM_SETCHARFORMAT = 1092;<br />
private const int EM_GETCHARFORMAT = 1082;<br />
private const int CFM_BACKCOLOR = 67108864;<br />
private const int SCF_SELECTION = 1;<br />
<br />
[StructLayout( LayoutKind.Sequential )]<br />
private struct CHARFORMAT<br />
{<br />
public int cbSize;<br />
public uint dwMask;<br />
public uint dwEffects;<br />
public int yHeight;<br />
public int yOffset;<br />
public int crTextColor;<br />
public byte bCharSet;<br />
public byte bPitchAndFamily;<br />
[MarshalAs( UnmanagedType.ByValArray, SizeConst = 32 )]<br />
public char[] szFaceName;<br />
<br />
public short wWeight;<br />
public short sSpacing;<br />
public int crBackColor;<br />
public int LCID;<br />
public uint dwReserved;<br />
public short sStyle;<br />
public short wKerning;<br />
public byte bUnderlineType;<br />
public byte bAnimation;<br />
public byte bRevAuthor;<br />
}<br />
<br />
[DllImport( "user32", CharSet = CharSet.Auto )]<br />
private static extern int SendMessage( HandleRef hWnd, int msg,<br />
int wParam, ref CHARFORMAT lp );<br />
#endregion<br />
<br />
#region Constructors<br />
public ExtendedRichTextBox() <br />
{<br />
}<br />
#endregion<br />
<br />
public Color SelectionBackColor<br />
{<br />
get<br />
{<br />
CHARFORMAT fmt = new CHARFORMAT();<br />
fmt.cbSize = Marshal.SizeOf( fmt );<br />
<br />
SendMessage( new HandleRef( this, Handle ), EM_GETCHARFORMAT,<br />
SCF_SELECTION, ref fmt );<br />
<br />
if ( ( fmt.dwMask & CFM_BACKCOLOR ) == 0 )<br />
return Color.Empty;<br />
<br />
int backCol = fmt.crBackColor;<br />
Color ret = ColorTranslator.FromWin32( backCol );<br />
<br />
return ret;<br />
}<br />
<br />
set<br />
{<br />
CHARFORMAT fmt = new CHARFORMAT();<br />
fmt.cbSize = Marshal.SizeOf( fmt );<br />
fmt.dwMask = CFM_BACKCOLOR;<br />
<br />
fmt.crBackColor = ColorTranslator.ToWin32( value );<br />
<br />
SendMessage( new HandleRef( this, Handle ), EM_SETCHARFORMAT,<br />
SCF_SELECTION, ref fmt );<br />
}<br />
}<br />
public void AppendText(String text,Color backcolor,Color color,Font font) <br />
{<br />
int len = this.Text.Length;<br />
this.Text += text;<br />
this.Select(len,text.Length-1);<br />
this.SelectionBackColor = backcolor;<br />
this.SelectionColor = color;<br />
this.SelectionFont = font;<br />
}<br />
}
I don't quite know what the problem is and moreover how the Selection properties really work. Anyone have any insight? Thanks.
|
|
|
|
|
|
Hi,
I´m trying to automate Microsoft Access from Microsoft Visual C# .NET with the following code. My problem is that all that is showed is an Access Window and not my
Access report. Can anyone tell me what I do wrong?
Access.Application oAccess = null;
oAccess = new Access.ApplicationClass();
oAccess.OpenCurrentDatabase(
"c:\\InvoiceDB.mdb", //filepath
false,null
);
//View report InvoiceFoundation
oAccess.DoCmd.OpenReport(
"InvoiceFoundation", //ReportName
Access.AcView.acViewPreview, //View
System.Reflection.Missing.Value, //FilterName
System.Reflection.Missing.Value,
Access.AcWindowMode.acWindowNormal,
System.Reflection.Missing.Value//WhereCondition
);
oAccess.Visible=true;
oAccess.CloseCurrentDatabase();
THX in advance
Thomas Andersson
|
|
|
|