|
thanks....that worked fine. And yes, this form is all labels. But now I have another issue. The first 4 labels on the form were placed on the form during development, and the next bunch are done at runtime. The runtime ones print in order, but the first 4 don't. #2 prints, then #1, then #3, then #4 due to the order I placed them on the form. Is there a way to 'reorder' these so the loop thru the label controls function does what I want it to? I even removed them and recreated them in the order I wanted them, but still they came out wrong. help?
|
|
|
|
|
The designer automatically uses Controls.AddRange to add them. This is in reverse order, so you can re-order them that way, so that they are added as 4, 3, 2, 1. You can also use View->Tab Order and select them in the correct order. This should, IIRC, cause the designer to re-order them as well, though you should double check.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
thanks for the fast reply! I did try to reorder by the taborder but it didn't do the trick. But I'll try the addrange. Thanks again!
|
|
|
|
|
My quick and dirty solution (there was no time to develop something more efficient):
1. Find maximum area of whole print
2. split it into printable pages (tiles)
for every page you print:
1. set offset of graphics object into current page
e.Graphics.TranslateTransform(-PrintRectangle.X+e.MarginBounds.Left, -PrintRectangle.Y+e.MarginBounds.Top+this.titleHeight);
2. create "window" for graphics:
e.Graphics.SetClip(PrintRectangle);
3. print EVERYTHING - all the controls you want in any order you want. That's the trick. Clip makes the rest for you
|
|
|
|
|
I accidently screwed up in my OnStart for my service by initializing my main thread before my argument checks and now after uninstalling the service, it is in the state of "Disabling." I've tried rebooting but it won't uninstall fully. I can't reinstall and I can't recompile, so does anyone know what I should do?
Thanks.
----
Xian
|
|
|
|
|
If you can't recompile, that's entirely a different problem, something you need to check, fix, and then recompile.
To get rid of the registry entry for the service, open regedit.exe and drill-down to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services. Find the key with the name (not the display name) of your service and delete it and reboot.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I couldn't recompile because the .exe was in use by the system. I managed to get it out via safe mode.
Thanks.
----
Xian
|
|
|
|
|
I'm coding a MDI form application. What I really want the form (not the controls it contain) to look like is similar to Office 2003, which reflects the theme the system is using. Could someone give me some help?
Thanks!
|
|
|
|
|
Unless you draw the UI elements with the theme data yourself, it's either all or nothing for applying visual styles.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Also, if you want the Office 2003 look, there are dozens of third-party controls out there (maybe even some free ones, though you get what you pay for often times). Just google.
There's a couple here on CodeProject as well, although - IMO - I don't think they even come close to Office 2003.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I can call EnableVisualStyle to make contained controls to have visula styles. But for the form itself, e.g. border colors, how do I make that happen?
|
|
|
|
|
I have never done this, but from reading I think it is possible. You can create a manifest file using XML to tell your application to use the operating system's style.
The file is placed in the same directory as your project, and is called myProject.exe.manifest
I don't have a link for it at the moment, but I'm sure information will be readily available using google
Hope it helps
|
|
|
|
|
I'm not really sure. I've never tried a callback with a class method before. You'll just have to try it. If you would, please reply whether or not it works.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
hi all,
I tried to implement auto -indentation feature in my editor.
using some ideas from codeguru and codeproject .
i did the following code.
The problem is whenver i press "enter" key
the tab is incremented automatically in the next line.
(straight logic .if u see the code u will unerstand)
but i want the following feature :
if() (Enter key)
{ (Enter key)
MessageBox(); (Enter key)
DrawString(..); (Enter Key)
while(i>0) (Enter key)
{ (Enter key)
bool b = false; (Enter key)
} (Enter key)
} (Enter key)
else (Enter key)
{ (Enter key)
MessageBox(); (Enter key)
}
each time when i press "Enter" key the tab position
is changed . How to identify and move the tab
key properly.
Following is the fundamental code which i did .
How to improve this logic further.
I am struck up.Please help me.
Source code :
private void richTextBox1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
string temp="";
int indent=0;
if(e.KeyCode == Keys.Enter)
{
// taking previous line
string temp = Convert.ToString(richTextBox1.Lines.GetValue(richTextBox1.GetLineFromCharIndex(richTextBox1.SelectionStart - 1)));
// GetIndent() is used to count the tabs in the previous line
indent = GetIndent(temp,12);
System.Diagnostics.Trace.WriteLine(indent);
//adding one tab further in the next line
for(int i=0;i
|
|
|
|
|
Hi guys,
First off im after some general help, Im in the wounderful process of learning C#, I have created a screen that I want the user to enter a username and password, this data comes form a access(20000) but i want to make it future proof, i mean at the moment im using access this is fine but I may want to use sql server 2000 to be the backend is their a way i can make switiching over easy in the future.
|
|
|
|
|
You have several options. The way that the .NET Framework is heading is the provider pattern, which is a pretty good system. See a recent article in MSDN - Provider Model Design Pattern and Specification, Part 1[^] - for more information.
A conceptually similar way without all the overhead of the typed class factories is what we currently use in our application.
Basically, you design an abstract class that performs the authentication. Then you extend this class (either in a different project or the same project) with Access-specific functionality. Later, you could extend this base class with SQL-specific functionality. In either case, you read-in a type from your application's .config file as a string (like "MyNamespace.MyAccessAuthClass, MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0123456789abcdef"). You could, for example, simply store this in the <appSettings> section of your .config file and associate that with a key, like "authenticator". You then get that type, create an instance of it, and cast it to your base class (or interface, whichever you prefer - use a base class if you want to have basic functionality implemented, or use an interface if you want no default implementation of anything):
string type =
ConfigurationSettings.AppSettings["authenticator"];
if (type == null)
type = "MyNamespace.MyAccessAuthClass, MyAssembly, " +
"Version=1.0.0.0, Culture=neutral, PublicKeyToken=0123456789abcdef"
AuthenticatorBase auth = null;
try
{
Type t = Type.GetType(type);
auth = (AuthenticatorBase)Activator.CreateInstance(t);
}
catch (Exception ex)
{
MessageBox.Show("Could not create the authentication package: " + ex.Message,
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Environment.Exit(1);
}
Obviously, the Type string is just an example, and you could use a partial type (namespace + classname, assembly name).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
need stuff about network with c#
thanks
|
|
|
|
|
Maybe you should elaborate on what you are looking for exactly.
Networks is not a very narrow topic.
|
|
|
|
|
System.Net namespace.
Due to technical difficulties my previous signature, "I see dumb people" will be off until further notice. Too many people were thinking I was talking about them...
|
|
|
|
|
I've been writing event handlers for my app. I have an event for a mousedown on the form, the event type is System.Windows.Forms.MouseEventArgs.
Using this event type I can type
e.Button to determine if the left or right mouse button
if i'm writing an event for an picturebox click the type is System.EventArgs. The is no method to determine the mouse button for this type. Using this event, is there any way to determine the mouse button, I want to use an if statement to ensure that only left clicks will allow the event code to change the picture box image and right clicks will do nothing.
Thanks in advance
|
|
|
|
|
Try the MouseDown event of your PictureBox . The event handler receives an argument of type MouseEventArgs .
|
|
|
|
|
Thanks for the reply... I have thought of that, however I don't want a mouse down to change anything... if the user clicks the mouse down on the pic and leaves the bounds of the pic it will still change the image. I would like the image changed only if there is a click. It seems I may have to write a MouseDown MouseUp combination to handle this... Can anyone think of an easier way to deal with this?
|
|
|
|
|
You can use the Control class static properties like MouseButtons, MousePosition and the instance methods PointToClient and PointToScreen.
For additional information refer the msdn documentation.
|
|
|
|
|
I used a MouseDown in combination with a MouseUp and tested to make sure that the mouse position was still inside that bounds of the pictureBox. If anyone else was having trouble with this here is the code:
<br />
private void NowPBox_MouseDown(object sender, MouseEventArgs e)<br />
{<br />
if(e.Button == MouseButtons.Left)<br />
leftClick = true;<br />
}<br />
<br />
private void NowPBox_MouseUp(object sender, MouseEventArgs e)<br />
{<br />
if(leftClick)<br />
{<br />
if(e.X + NowPBox.Left >= NowPBox.Left && e.X + NowPBox.Left <= NowPBox.Right)<br />
{<br />
if(e.Y + NowPBox.Top >= NowPBox.Top && e.Y + NowPBox.Top <= NowPBox.Bottom)<br />
{<br />
if(!NowPBox.PressedState)<br />
{<br />
this.NowPBox.Image = this.NavButtons.Images[2];<br />
NowPBox.PressedState = true;<br />
<br />
if(SkinsBox.PressedState)<br />
{<br />
this.SkinsBox.Image = this.NavButtons.Images[3];<br />
SkinsBox.PressedState = false;<br />
}<br />
<br />
this.panel1.Visible = false;<br />
this.panel2.Visible = true;<br />
}<br />
}<br />
}<br />
}<br />
}<br />
|
|
|
|
|
Hi, I am trying to return a BSTR from a C++ function that takes a single BSTR argument. I am using the ATL type CComBSTR. My C++ function looks as follows:
extern "C" BSTR __stdcall MyStringFunction( BSTR s )<br />
{<br />
std::string str = string((LPSTR)s);<br />
...<br />
...<br />
return CComBSTR(str.c_str());<br />
}
At the moment my C# declaration looks like this:
[DllImport(@"C:\MyDll.dll", CharSet = CharSet.Unicode)]<br />
[return : MarshalAs(UnmanagedType.BStr)] public static extern string MyStringFunction( [MarshalAs(UnmanagedType.BStr)] string s );
I have had varying success with different combinations. When I don't add the MarshalAs attribute to the return string, I get the string back ok, but when it gets large ( a few 1000 characters) , I hit problems. With the current declaration, which according to documentation is correct, I only receive the first two characters.
Does anyone know, or can suggest what the problem with my approach is? I am aware of Unicode/Ansi issues, but as far as I can tell, what I have should work.
Thanks,
Christopher
The bomb lives only as it is falling
|
|
|
|