Can I run any app inside a "special" control
I'm looking for a control which will allow me to run any app inside a
Window/Panel/Tab
Specifically I want to be able to save xml files created from XMLSpy to a
database in a very specific format - I'd like to run XMLSpy in a window
inside this app, then save/retrieve files to/from a sql server db. Not
quite seamless integration, but better than nothing.
Thanks Tag: Sources for threads Tag: 86004
Menu Shortcut Key Not working
I have an MDI winform application. One of the menu items is using CTRL+U as
the shortcut and it will not invoke the menu item. Here is a list of things
I have tried to resolve the problem.
1) Tested CTRL+U in Word to make sure that the keys are working properly.
Success
2) Re-Assigned the menu item a different shortcut. Success
3) Re-Assigned a different menu item the CTRL+U shortcut. Failure
4) Created a new project with one form, and a menu item with the CTRL+U
shortcut. Success.
5) I can hot key to the menu item (the underllined letters for the menu
items). Success
6) I can click on the menu item. Success
Controls on the MDI Parent form
1) CDDB control
2) MCI control
3) menu items
Controls on the MDI child form the menu item is affecting
1) Labels
2) text boxes
3) tab control with 2 pages
4) 2 grid controls (1 per page)
5) toolbar
Any thoughts/suggestions on why CTRL+U won't work?
Thanks,
Greg Tag: Sources for threads Tag: 86002
Making it possible for user to move controls on form, how?
How can I make it possible for a user to move a control on a form by
selecting it and then using the arrow keys to move it to a new location? For
instance suppose I have a form that represents the output of a cheque and I
want the user to be able to move the date and amount fields so that they cn
be printed out at the correct location on his preprinted cheque stock?
Any help or a pointer to some sample code would be greatly appreciated.
Thanks,
RD Tag: Sources for threads Tag: 86001
Refreshing Form on Process
Hello,
I have a windows application written in VB .NET which pulls a lot of data
from different databases into one source. This often takes a long time and
therefore I track the progress using a progress bar and a status bar.
When the program is running and I use another application the form turns
white and doesn't refresh itself until the process is complete. Could anyone
advice me/provide a VB example of the best way to keep a windows form
refreshed when running, but still restrict the user from setting off another
process?
Many thanks for your advice. Tag: Sources for threads Tag: 85995
Reusing GUI elements
Hello people,
I'm new at .NET development so forgive me if I ask about the obvious.
There are several forms in my application that have similar groups of =
controls.
I would like to extract the UI and functionality into a single entity so =
I can reuse it in the application.
What is the easiest way to implement it?
(I don't really want to create a standalone control since the "grouping" =
only makes sense inside this particular application).
Thank you,
Alex.
--=20
Please replace myrealbox with alexoren to reply by email. Tag: Sources for threads Tag: 85992
Nasty bug with OwnerDrawn context menus on a ComboBox
Have a look at the code below. It's a really simple example where I
have added two controls to a form, a textbox and a combo box. Both add
owner drawn context menus to the controls, but the combobox will NOT
draw custom drawn context menu item. I have tried EVERYTHING (deriving
from MenuItem and even tried calling TrackPopupMenuEx directly), but
it just won't work!
I am currently reflecting over the combobox source code (oh joy!), but
if anyone can help me, I will BE SOOOOO VERY GRATEFUL!!!!
thanks
andrew
using System;
using System.Drawing;
using System.Diagnostics;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace ComboContextBug
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private ComboTest comboBox1;
private TextBoxTest textBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.comboBox1 = new ComboContextBug.ComboTest();
this.textBox1 = new ComboContextBug.TextBoxTest();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// comboBox1
//
this.comboBox1.Location = new System.Drawing.Point(180, 32);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(121, 21);
this.comboBox1.TabIndex = 0;
this.comboBox1.Text = "comboBox1";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(180, 98);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(121, 20);
this.textBox1.TabIndex = 1;
this.textBox1.Text = "textBox1";
//
// label1
//
this.label1.Location = new System.Drawing.Point(8, 20);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(168, 52);
this.label1.TabIndex = 2;
this.label1.Text = "Right click this combo and you will see that
the OwnerDrawn item does NOT appear!" +
"";
//
// label2
//
this.label2.Location = new System.Drawing.Point(8, 86);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(168, 52);
this.label2.TabIndex = 3;
this.label2.Text = "Right click this textbox and you will see that
the OwnerDrawn item DOES appear!";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(336, 157);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.comboBox1);
this.Name = "Form1";
this.Text = "Combo Context Menu Bug";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
}
public class ComboTest: ComboBox
{
public ComboTest()
{
base.ContextMenu = new ContextMenu();
MenuItem mnuOwnerDraw = new MenuItem();
mnuOwnerDraw.Text = "This text WILL NOT appear on a ComboBox!";
mnuOwnerDraw.OwnerDraw = true;
mnuOwnerDraw.DrawItem +=new
DrawItemEventHandler(mnuOwnerDraw_DrawItem);
mnuOwnerDraw.MeasureItem +=new
MeasureItemEventHandler(mnuOwnerDraw_MeasureItem);
base.ContextMenu.MenuItems.Add(0, mnuOwnerDraw);
MenuItem mnuNormalDraw = new MenuItem();
mnuNormalDraw.Text = "This text WILL appear!";
mnuNormalDraw.OwnerDraw = false;
base.ContextMenu.MenuItems.Add(0, mnuNormalDraw);
}
private void mnuOwnerDraw_DrawItem(object sender, DrawItemEventArgs
e)
{
MenuItem menu = sender as MenuItem;
e.Graphics.DrawString( menu.Text, this.Font,
SystemBrushes.ControlText, e.Bounds.X + 15, e.Bounds.Y );
}
private void mnuOwnerDraw_MeasureItem(object sender,
MeasureItemEventArgs e)
{
MenuItem menu = sender as MenuItem;
string text = menu.Text;
e.ItemWidth = (int)(e.Graphics.MeasureString(text,
this.Font).Width) + 3;
e.ItemHeight = (int)(e.Graphics.MeasureString(text,
this.Font).Height) + 2;
}
}
public class TextBoxTest: TextBox
{
public TextBoxTest()
{
base.ContextMenu = new ContextMenu();
MenuItem mnuOwnerDraw = new MenuItem();
mnuOwnerDraw.Text = "This text WILL appear on a Textbox!";
mnuOwnerDraw.OwnerDraw = true;
mnuOwnerDraw.DrawItem +=new
DrawItemEventHandler(mnuOwnerDraw_DrawItem);
mnuOwnerDraw.MeasureItem +=new
MeasureItemEventHandler(mnuOwnerDraw_MeasureItem);
base.ContextMenu.MenuItems.Add(0, mnuOwnerDraw);
MenuItem mnuNormalDraw = new MenuItem();
mnuNormalDraw.Text = "This text WILL appear!";
mnuNormalDraw.OwnerDraw = false;
base.ContextMenu.MenuItems.Add(0, mnuNormalDraw);
}
private void mnuOwnerDraw_DrawItem(object sender, DrawItemEventArgs
e)
{
MenuItem menu = sender as MenuItem;
e.Graphics.DrawString( menu.Text, this.Font,
SystemBrushes.ControlText, e.Bounds.X + 15, e.Bounds.Y );
}
private void mnuOwnerDraw_MeasureItem(object sender,
MeasureItemEventArgs e)
{
MenuItem menu = sender as MenuItem;
string text = menu.Text;
e.ItemWidth = (int)(e.Graphics.MeasureString(text,
this.Font).Width) + 3;
e.ItemHeight = (int)(e.Graphics.MeasureString(text,
this.Font).Height) + 2;
}
}
} Tag: Sources for threads Tag: 85991
Dangling process, when calling ShowDialog twice from Main
hi,
i've used jason clarks recommendations for handling unhandled
exceptions in my winforms app
(http://msdn.microsoft.com/msdnmag/issues/04/06/NET/default.aspx).
if an unhandled exception happens, i open up an 'Error-Logger' form,
which sends the exception to a web service. here is the relevant code:
[STAThread]
public static void Main()
{
try
{
SubMain();
}
catch (Exception e)
{
HandleUnhandledException(e);
}
}
public static void SubMain()
{
AppDomain.CurrentDomain.UnhandledException += new
UnhandledExceptionEventHandler(OnUnhandledException); // CLR
Application.ThreadException += new
System.Threading.ThreadExceptionEventHandler(OnGuiUnhandedException); //
Windows Forms
Application.Run(new MainForm());
}
public static void HandleUnhandledException(Object o)
{
if(o == null)
{
MessageBox.Show("An unknown error has occurred", "Error");
return;
}
Exception ex = o as Exception;
if (ex != null)
new ErrorLogger(ex).ShowDialog();
}
this approach works very well. the problem of a dangling process
occurs if the user closes the ErrorLogger form before it has finished
reporting the error. A ThreadAbortException happens (which i catch and
ignore) in ErrorLogger, and the error logger form closes. if i then
close the mainform, the process is left dangling in task manager with
no windows open.
this only happens if the user kills the errorlogger form. the
errorLogger form calls the web service on a worker thread, but i am
careful to Abort this thread in Dispose() and Form.Close() and even
when the ThreadAbortException happens.
is there any way for me to work around this? maybe the application is
creating two UI threads because ShowDialog is called twice, and only
one of those threads gets properly terminated when the application is
closed?
thanks for any help
tim Tag: Sources for threads Tag: 85989
detecting instances of my App
I want to allow running only one instance of my Application.
How can I detect that a previous instance of my WinForm App is running in
order to stop the second instance?
--
thks Tag: Sources for threads Tag: 85985
Using The NativeWindow Class To Draw A GDI Type Circle On Top Of A DataGrid Possibly In The Override OnPaint
I have a requirement to put a GDI style circle or rectangle border around
the selected row of a datagrid/ It will overlap into the row above and below
the selected row. Doing this in a the OnPaint of a subclassed
DataGridTextBoxColum dos not seem like a practical way to do it.
I have subclassed a DataGrid and overridden the OnPaint as such:
protected override void OnPaint(PaintEventArgs pe)
{
base.OnPaint(pe);
// Create pen.
Pen blackPen = new Pen(Color.Green, 2);
// Create location and size of rectangle.
float x = 15.0F;
float y = 53.0F;
float width = 500.0F;
float height = 20.0F;
// Draw rectangle to screen.
pe.Graphics.DrawRectangle(blackPen, x, y, width, height);
}
It works but has refresh problems.
Last week Bob Powell [MVP] suggested that I use a NativeWindow class to
solve this problem. I've just had the time to get back to this and not being
a former C++ person, etc., etc., etc. maybe someone can help with this.
The MSDN help screen for the NativeWindow class is this link:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformsnativewindowclasstopic.asp
It has an example and in the subclassed NativeWindow constructor it creates
a button:
public MyNativeWindow(Form parent)
{
..see help example
}
Can someone advise me on where my code above that paints the Rectangle
should go in this NativeWindow example? Tag: Sources for threads Tag: 85977
Creating DesignerVerbs for a Reflection.Emit-ed class for use in a PropertyGrid
Hi,
I've hit a bit of a brick wall in my use of the PropertyGrid control.
I am writing a Windows Forms application that does the following:
- dynamically create a class using Reflection.Emit - the class simply
holds a number of properties ("Name", "Description", etc).
- pass the class to a PropertyGrid control which then renders the
properties for the user to edit.
This is all working fine, and I have even added my own Category and
Description attributes to the properties which are showing up
successfully in the PropertyGrid. My problem is that I would also like
to add a couple of DesignerVerbs to the class, so that I can offer
"Add Property" and "Remove Property" functions in the PropertyGrid. I
have set the CommandsVisibleIfAvailable flag on my PropertyGrid, and
attempted to set the Designer attribute on my dynamically-created
class. The Designer attribute points to a custom ComponentDesigner
class, in which I have defined the DesignerVerbs. However, the verbs
are not being shown in the PropertyGrid.
I may have a lead in that the Attributes property of my TypeBuilder
class still says "NotPublic" after I SetCustomAttribute. But does that
mean the contents of the Attributes collection are not public, or that
my class' only attribute is "NotPublic"?
Any ideas on something I might have missed? Below is some example
code, in the hope that it jogs someone's memory! I'd be happy to post
anything else that may be relevant.
Cheers
Lee
**********************************************
*** snippet from DynamicCmSchemaCreator.cs ***
*** creates the DesignerAttribute using my ***
*** custom ComponentDesigner class ***
TypeBuilder typeBuilder = moduleBuilder.DefineType
(
DynamicType,
TypeAttributes.Class,
typeof(Component)
);
// Apply the Designer attribute, supplying our own ComponentDesign
class
CustomAttributeBuilder customAttributeBuilder = new
CustomAttributeBuilder
(
typeof(DesignerAttribute).GetConstructor(new Type[] { typeof(Type)
}),
new object[] { typeof(DynamicCmSchemaComponentDesigner) }
);
typeBuilder.SetCustomAttribute(customAttributeBuilder);
*******************************************
*** DynamicCmSchemaComponentDesigner.cs ***
*** the componentdesigner I attach to ***
*** the dynamic class ***
public class DynamicCmSchemaComponentDesigner : ComponentDesigner
{
private const string AddPropertyVerb = "Add Property";
private const string RemovePropertyVerb = "Remove Property";
private DesignerVerbCollection verbs;
private void OnAddPropertyVerb(object sender, EventArgs e)
{
System.Diagnostics.Debug.WriteLine("Processing Add Property");
}
private void OnRemovePropertyVerb(object sender, EventArgs e)
{
System.Diagnostics.Debug.WriteLine("Processing Remove
Property");
}
public override DesignerVerbCollection Verbs
{
get
{
if (verbs == null)
{
verbs = new DesignerVerbCollection();
verbs.Add(new DesignerVerb(AddPropertyVerb, new
EventHandler(OnAddPropertyVerb)));
verbs.Add(new DesignerVerb(RemovePropertyVerb, new
EventHandler(OnRemovePropertyVerb)));
}
return verbs;
}
}
}
****************************************
*** snippet from MainForm.cs ***
*** creates the dynamic class and ***
*** passes it to the propertygrid ***
object dynamicCmSchema = DynamicCmSchemaCreator.CreateDynamicCmSchema
(
node.CmSchema.Properties
);
this.propertyGrid.SelectedObject = dynamicCmSchema;
******************************************* Tag: Sources for threads Tag: 85969
Does MS will provide a RCP like Eclipse RCP or Macromedia Flex?
The smart client offered by MS is more like a concept and the features is
more separately.
I think the client application vender need a clien side framework like
Eclipse RCP.
Does MS or any others provide one for .NET?
--
Niciyou
Beijing, China Tag: Sources for threads Tag: 85968
How to get the selected node of TreeView when context menu popup?
When user right click the tree node, a context menu popup. But I can not get
the node clicked calling TreeView.SelectedNode property correctly because the
default selection behavor of TreeView is left click.
How can I get the correct tree node when context menu popup?
Thanks. Tag: Sources for threads Tag: 85963
Architectural Guide to Winforms Development?
I'm primarily a class library developer, but I've written a few small
tools in my day using forms (VB6/Java/Winforms) and my libraries have
been used in larger forms apps. The thing is, I've never seen a well
architected forms app in my 12-year career and I'm wondering if there
is a book or some resource that deals specifically with designing a
forms app.
In the class library/component world, it's relatively easy to implement
design patterns and graceful object-oriented designs, I suppose because
we don't have to keep so many balls in the air and visually interact
with users. Are there common patterns and designs for forms
development? I understand and have implemented simple
Model-View-Controller and Model-View designs, but I'd like to know of
other designs (are there any?) and how compatible they are with
WinForms development. I would love to have a resource that goes deep
into some of the common issues with forms like forms management (ie
organizaing, caching, reusing), use of dialogs, data encapsulation,
messaging between GUI objects, and so on. I'm quite comfortable with
the mechanics of WinForms, so I'm looking for something more
design-oriented.
Thanks for any pointers. Tag: Sources for threads Tag: 85962
Property grid with listview
I'm using a listview as my drop down in my property grid editor and
everything for the most part works fine. However, if I don't have the
properties view pinned and I click on another property while the drop down
is open, it seems to give me an error of Invalid Property value. The
details say Object type cannot be converted to target type. This does not
happen if I have the properties window pinned down though. I don't
understand why this is happening and how I can stop it.
Lance Johnson Tag: Sources for threads Tag: 85955
Timers and threading
Hi,
I am writing a program that handles authentication, and based on the user's
permission level, can do certain things in the program. However, I want to
have a global 10 minute time out in case a user is idle for that amount of
time.
To do this, I am using a timer from System.Timers. At the end of the 10
minute timeout, I want the timer to call methods within the program to limit
access to certain functionality. However, the problem is that the timer is
working on a different thread, and so calls to these methods will also be on
this thread, which is not the owner thread of the controls I am trying to
alter, and so I'm getting an exception.
How can I tell the owner thread to manipulate the controls?
Thanks! Tag: Sources for threads Tag: 85952
dyn buttons
I'd like to add buttons dyn to a form, i can create new buttons, new .name &
.text properties, but i can't figure out the eventhandler
example I want to create a grid of buttons based on the itemno from a
database, then clik on the button & have it add that itemno to a list box,
or database...
Thanks!!
--
Scott Kramer
CDS Technologies, Inc.
www.team501.com Tag: Sources for threads Tag: 85951
User controls: Propagating new changes to placed controls
Hello,
I've taken a button component and extended it's functionality by adding a
couple small methods and properties. This control is contained within my
project tree and has been used on various locations of my form. Now, I want
to add another property to the control. In doing so I had hoped that this
change would have been propagated to the older controls, however, it's only
showing up in a control that's placed on the form for the first time. How
do I make the change propagate to the other controls without deleting and
replacing them?
Thanks,
Chris Tag: Sources for threads Tag: 85948
optimize .net app with a lot of graphic background images
Hello,
I have a winform that looks beautiful. All the panels have bacground
images. I even have rollover buttons for the main navigation. My
problem is that it loads slower than a "plain" winform app. Also when
minimizing the form and switching back to my application it has "blank
sections" that occur for a few moments. Right now my application is
just a shell, there is no "programming code". All the code has been
done in the forms designer except for the rollovers.
What can I do to
1) optimize the performance overall of the application
2) make repaints quicker
3) generally run faster
Right now the only way I know to "optimize" the application is (a)
write efficient code and (b)Setting the "Configuration" to "Release"
and (c) setting "Optimize Code" to "true".
Thanks,
Tom Tag: Sources for threads Tag: 85945
BUG: SizeGripStyle does not support XP visual style (themes)
This is probably question to Microsoft WinForms support.
My C# application has XP visual styles enabled through
Application.EnableVisualStyles() call and everything is fine except for
(at least) grip of my Form1 app-wizard created form - it still old
style grip. However, when I show OpenFileDialog from my application -
this system dialog has correct (XP) style.
Boris Tag: Sources for threads Tag: 85944
UserControl Text property
I have a control that derives from UserControl. In addition, I have
overriden the Text property and put the attributes on it so it shows up int
the designer. However, it will not save the value no matter what I do.
I've applied every attribute I can think of. Any help in this matter is
appreciated.
Lance Johnson Tag: Sources for threads Tag: 85941
Toolbar on TerminalServer runninf with 256 colors
Hello all together.
I have little bit trouble with a Toolbar which i want to use in vb.net.
I have placed in Toolbar on my form and added some buttons to it. In
addition i have also placed an imagelist with images that are all gifs
optimized for 256 color (to be more precisely: i have optimized them so that
they fit to the windows-system-color-palette using 256 colors). than i
assigned these images to the buttons on my toolbar.
So far so good. everything looks as expected in the designer. But when i run
the application in a terminal-server-environment which uses 256 colors the
images don't look the same as in a normal-environment. they look if they have
only 16 colors or somethink like that.
So i put one of my images stored in the imagelist on a normal button
situated on the form. When i re-run the application in a
terminal-server-environment the normal button looks like expected where else
the toolbar buttons looks ugly.
Can someone please point me to the right direction to get manged it. Or
perhaps does somebody has some sample code?
Thanks in advance,
Rainer Arnken Tag: Sources for threads Tag: 85939
FIFO in a richTextBox
I have a richTextBox that is receiving lots of data over a serial port. The
problem is that the display of the text gets slower and slower as more and
more text is added (using .AppendText). Is there a way to limit the text
box to some fixed number of lines (or characters) of text such that the
first text in would automatically get dropped from the text box when the
limit is reached? I've tried using SelectionStart combined with
SelectionLength to select and cut the first line of text when the limit is
reached, but that gets the vertical scroll bar bouncing up and down as the
code bounces between adding new text and deleting old text. This results in
even worse performance of the text box.
Any thoughts or suggestions?
Thanks,
Ron Tag: Sources for threads Tag: 85937
401 error when trying to read my app config (app hosted on webserv
I have a windows forms app that I am launching with a url.
I worked through the trust issues and it is working well except for one thing.
When I try to use the ConfigurationSettings.AppSettings class to read a
value from my application config file it fails. The virtual dir is setup for
integrated auth only.
What happens (according to the iis logs) is the attempt to read the file
gets a 401 response, then gives up. Normally this would be followed by one
more 401 then a 200 once the client finally sends the correct credentials.
This is what shows up for other files such as the .exe and so forth.
I assume the difference is that IEexec is handling the authentication
challenges for loading the .exe, but what do I need to do so the framework
will handle the authentication challenge while using the appsettings method ?
BTW if I allow anonymous on the virtual this works just fine.
Ideas ?
Tim Tag: Sources for threads Tag: 85931
asp.net
i want to help for how to code this
if i entering the datas in first form then that display in second form for
what ever i entered in first form(confirmation )
i know about first form insert datas but i dont know how to display in
second form can i help you
please consider this
thank u
sutha
--
Message posted via http://www.dotnetmonster.com Tag: Sources for threads Tag: 85929
form hide (or visible = false)
Hi,
In the form's Load event handler I'm trying to hide the form, but still the
form is visible although the Visible property is set to false.
Only if the ShowInTaskBar property is set to false too, it is not visible.
Why?
Isn't there a way to hide a form from its Load event handler but to display
it still in the task bar?
Here is the code:
// handler for the Load event
private void FrmLifetimeDemo_Load(object sender, System.EventArgs e)
{
this.Visible = false;
this.ShowInTaskbar = false;
}
--
Ohad Young
Medical Informatics Research Center
Ben Gurion University
Information System Eng
Office Phone: 972-8-6477160
Cellular Phone: 972-54-518301
E-Mail: ohadyn@bgumail.bgu.ac.il Tag: Sources for threads Tag: 85928
PrinterSettings.PaperSources
Does anyone know how to switch trays(paper source) when printing a
multi-page document?
Here is some code I have tried, but I can never get the printer to grab from
another tray during the print of a document. If I seperate the two calls
into Page 1 and Pages 2-4, then the printer will grab from the appropriate
tray. To do this, requires I call the objPD.Print two times. This
seperates them in the print buffer, which we are trying to avoid doing.
Friend WithEvents objPD As System.Drawing.Printing.PrintDocument
Private Sub PrintMe()
Dim ps As New System.Drawing.Printing.PrinterSettings
ps.MaximumPage = 4
ps.MinimumPage = 1
ps.PrintRange = Printing.PrintRange.SomePages
ps.FromPage = 1
ps.ToPage = 4
ps.PrinterName = printerName 'Printer name was captured eariler by user
objPD.PrinterSettings = ps
m_currentPrintingPage = 1
m_lastPrintingPage = 4
objPD.DefaultPageSettings.PaperSource =
objPD.PrinterSettings.PaperSources(1) 'goldenrod colored sheet
objPD.Print()
End Sub
'Then in the printpage event:
Private Sub objPD_PrintPage(ByVal sender As System.Object, ByVal e As
System.Drawing.Printing.PrintPageEventArgs) Handles objPD.PrintPage
e.HasMorePages = False
If m_currentPrintingPage <= m_lastPrintingPage Then
If m_currentPrintingPage = 1 Then 'first page gets a goldenrod sheet
objPD.DefaultPageSettings.PaperSource =
objPD.PrinterSettings.PaperSources(1) 'goldenrod sheet
e.PageSettings.PaperSource = objPD.PrinterSettings.PaperSources(1)
'goldenrod sheet
'neither of the two above lines work, either together or seperate
Else 'all other sheets in this document get plain white paper
objPD.DefaultPageSettings.PaperSource =
objPD.PrinterSettings.PaperSources(5) 'White sheet
e.PageSettings.PaperSource = objPD.PrinterSettings.PaperSources(5)
'White sheet
'neither of the two above lines work, either together or seperate
End If
ReportDrawPageNET(e.Graphics) 'create the page that goes to the printer
m_currentPrintingPage += 1
If m_currentPrintingPage <= m_lastPrintingPage Then
e.HasMorePages = True
Else
e.HasMorePages = False
End If
e.Graphics.Dispose()
End If
End Sub
Thanks!
--
Todd Acheson Tag: Sources for threads Tag: 85926
FolderBrowserDialog.FolderBrowserDialog does not work on Windows 2
I found out this problem very long time ago. I set FolderBrowserDialog to
false but the New Folder button still shows on Windows 2000. At that time, I
thought it may be related to Windows 2000 itself and SP3/SP4 would eventually
fix it.
But at the beta 2 release of .NET FX 2.0, the problem still exists on
Windows 2000/SP4. Note that this problem does not exist on Windows XP/2003 (I
do not have the chance to test it on Windows 98).
Will Microsoft fix this *small* problem? Tag: Sources for threads Tag: 85920
Splash screen?
Hi all,
I've created a splash screen for an MDI application and
moved the main application's entry function in the splash
screen's class.
Inside the Main(), I run the following:
[STAThread] static void Main ()
{
Application.Run (new FormSplash ());
}
In the Load event of FormSplash, I start a timer that
increases the form's Opacity value and updates a progress
bar and a label.
Finally, I start another thread to run the MDI form and
close the splashscreen:
private void FormSplash_Load (object sender,
System.EventArgs e)
{
timer_Refresh.Start();
...
... // connect to db, initialize some static
objects etc...
...
// Run main MDI application
Thread thread = new Thread (new ThreadStart
(FormMain.Start));
thread.IsBackground = false;
thread.Start();
this.Close()
}
The problem is that even if timer is enabled, it doesn't
get into the Tick event's implementation, until the splash
form is being closed with Close().
Any suggestions? Is there a simpler way to have a splash
screen created and shown before the main application's
form?
Thanks in advance,
Pascal Tag: Sources for threads Tag: 85917
Custom OpenFileDialog
Hi,
It seems this one comes up all the time but I could not find anything.
I need a customized FileOpenDialog. As I could not find any I decided to
write my own.
I have the following questions:
1. How do I find information about logical devices? There are functions
returning logical drives' names, but no info what they are (floppy, CD-ROM,
hard drive)
2. How do I browse the network (if there is one)?
Thank you Tag: Sources for threads Tag: 85911
Starting different forms in a project
If I have a WinForms project - what's the best strategy for opening
different forms from different shortcut icons?
Basically I want to lump a few different (but related) apps into the one
assembly, and have a number of icons in the start menu.
Is there a way to go about this (like passing parameters to Main or
something)???
Many thanks.
====
Phil Tag: Sources for threads Tag: 85904
[ANN] March 29, 2005, "ADO.NET with Visual Basic .NET" chat
Every application uses data. Join members of the Visual Studio and SQL teams
(Steve Lasker, Eric Gruber, Kris Langohr, Steve Stein, Riaz Khan, Eddie
Goziker, and John Chen) for a discussion of the best approaches for working
with data in your applications.
Date:
March 29, 2005
1:00 - 2:00 P.M. Pacific time
4:00 - 5:00 P.M. Eastern time
21:00 - 22:00 GMT
(For a list of the start time in several local time zones, please see
http://www.timeanddate.com/worldclock/fixedtime.html?month=11&day=2&hour=13&min=0&sec=0&p1=234)
Outlook Reminder:
http://msdn.microsoft.com/chats/outlook_reminders/050329_DN_ADONET.ics
Location (click the name of the chat to enter the chat room)
http://www.microsoft.com/communities/chats/default.mspx#050329_DN_ADONET
For more information about Visual Basic .NET, see
http://msdn.microsoft.com/vbasic/
To see a list of upcoming chats or set a reminder for this chat, see
http://msdn.microsoft.com/chats.
For archives of previous chats, see
http://msdn.microsoft.com/chats/recent.asp.
Thanks!
Jason Cooke
Visual Basic Team
========
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.
(c) 2005 Microsoft Corporation. All rights reserved. Tag: Sources for threads Tag: 85899
Passing Information/address form properties - VB.NET
I have a basic question about how do you change the information on a Form
from another Form, not a dialog.
Example: I have a MDIform which is the startup form for the project. I
call a child form to put in setup information which is written to the
Registry. As a result I need to update the Text (Title) of the MDIForm and a
StatusBar Panel(0) which is also on the MDIFORM. In VB6 this was easy.
I has tried using classes but can not seem to get it to work. I can pass to
a new instance but not to the current instance.
Help
Leo Tag: Sources for threads Tag: 85898
Accessing a String Resource
It seems like it should be so simple but I'm having trouble with the baseic
C# code for accessing a String resource. I need to be able to do this both
from a WindowsForms application and a Console application.
When I do...
ResourceManager RM = new ResourceManager("ProjectName",
Assembly.GetExecutingAssembly());
m_ConnString = RM.GetString("ConnectionString");
I get a "MissingManifestResourece Exception" on the GetString() line. But
I'm not sure if this is because "ConnectionString" can't be found within the
standard Resources.resx file included when one creates a Application Project
in VS or if it's because I don't know exactly how to provide the parameters
for the ResourceManager constructor.
Help?
Alex Tag: Sources for threads Tag: 85897
Shutdown multithreaded app or Thread.Abort
Hello,
I have a multithreaded app that did not have problem closing down on XP
computer.
But on Windows server 2003, one thread is not stopping and I can not delete
the process from task manager either. This is Windows Form app. I am using
Thread.Abort to cancel threads. It is hard to catch wich thread hangs. How
can I debug better? any tools that I can use? Is Thread.Abort bad? Thanks. Tag: Sources for threads Tag: 85895
Form.Update in Windows Xp
Hello everyone:
I'm developing an application that executes a long algorithm and I want to
show a progress bar, and every time the progress bar is updated, I also
update the main window, so the window refreshes the invalidated areas.
I was developing in win2k and everything works fine, but now Im using WinXp,
and the form.Update () is ignoring my calls, so the application looks like a
big white box and the user can not know where the progress bar is.
Is that a bug? (Im afraid it is a feature..) Is there any way to do that
without having to create threads or some things like that?? Tag: Sources for threads Tag: 85894
Rich Client Framework (like MFC?)
Where is MFC for .NET? I need something ~similar~ for .NET. Please read on...
We are embarking on a project for which we need to build a pluggable rich
client framework. We have 15 applications which we are going to integrate
into a singe common desktop, sort of like the dashboard model of old. We
need to have a shell which will act as the host for a bunch of application
"widgets". The shelll needs to support things like common UI realizations,
shared state (or context) and implments the MVC or PAC (preferred) patterns.
We had a bakeoff with Eclipse/ICWT the Java based framework and won - Doh!.
Our plan at the time was to use a new MS Block which supported exactly these
features, but it has been tied to Whidbey and therefore is not an option for
our Oct release. Of course to write this from scratch would also put an Oct
release at risk.
Anyone know of a third party product which comes close? I already checked
out Ghengis and it's the closest thing so far, but is not nearly robust
enough.
Thanks,
curt Tag: Sources for threads Tag: 85890
Reflection and Menu Merging in MDIs
We have an MDI application that looks for forms in which a common interface
has been implemented. We can instantiate the forms and display them as
children of the mdi and use the functionality on them.
The problem is that the menus don't show up. They don't even show up on the
form itself, much less merge with the mdiparent menus
We have changed the modifiers on the menu and on each item in the menu to
public so they can be seen outside the assembly. We have tried not making
the form an mdichild and using it as a stand-alone application (still
instantiated by the mdi, although not as a child). The child form does
appear in the 'windows' list as a child of the mdi.
Is there any way to make available to the mdi, the menu on a child form
instantiated through reflection? Tag: Sources for threads Tag: 85886
Regional Settings
Hi!
How can set Regional settings in rum-time mode?
For example How can set decimal separator to "." in VB.NET?
--
--
Cumprimentos,
David de Passos
--------------------------------------------------------------
RCSOFT, Lda.
E-Mail: passos@rcsoft.pt
Móvel: +351 966931639
Telefone: +351 239708708
Fax: +351 239708701
Tel. Directo: +351 239708705 ext. 401 Tag: Sources for threads Tag: 85885
Skin enabled apps
Hi, I'm looking for some documentation about developing skin enabled apps
(let's say desktop WinForms apps) and all I can find is about Mobile Apps.
Are there any design patterns (or anything else) that I should follow to
enable skins in my app or should I build it from scratch?
Thanks a lot,
Regards,
Victor Tag: Sources for threads Tag: 85882
Secure replication
Hi
I am developing a smart client application.
I have to push the client side data back to the server side and vise versa
what would the most secure way of doing this
-SQL SERVER MERGE Replication
- Web Services ?
Anyway else
Could anybody help me out. Tag: Sources for threads Tag: 85879
ComboBox find item based on value
Hi,
Can anyone help, I want to get a reference to a combobox item based on the
item's value rather than the text (basically what I am asking is, is there a
function like 'FindStringExact' for values) , does anyone know how to do
this?
Thanks,
Nicky Tag: Sources for threads Tag: 85878
Can't display dataset in windows form datagrid
Hi all, i have a window application which make use of a timer class, whereby
every 5 seconds i have to refresh a datagrid,below is the codes
Public Sub TimerFired(ByVal sender As Object, _
ByVal e As System.Timers.ElapsedEventArgs)
'Label1.Text = "Server Time = " & e.SignalTime.ToString
tape()
end sub
Private Function tape()
Dim i As Integer
Dim ds3 As New DataSet
Dim ds4 As New DataSet
ds4 = a.RetrievePatient1()
Dim foodtable As DataTable
Dim idcolumn As DataColumn
Dim namecolumn As DataColumn
Dim foodemandcolumn As DataColumn
Dim row As DataRow
'make a table
foodtable = New DataTable("Food")
'make a column
idcolumn = New DataColumn("PatientID")
idcolumn.DefaultValue = "<PatientID>"
'idcolumn.DataType = Type.GetType("System.string")
foodtable.Columns.Add(idcolumn)
namecolumn = New DataColumn("Name")
idcolumn.DefaultValue = "<Name>"
'idcolumn.DataType = Type.GetType("System.string")
foodtable.Columns.Add(namecolumn)
foodemandcolumn = New DataColumn("DemandFood")
foodemandcolumn.DefaultValue = "<DemandFood>"
'idcolumn.DataType = Type.GetType("System.string")
foodtable.Columns.Add(foodemandcolumn)
'a.RetrievePatient(patID)
'add row of data
For i = 0 To ds4.Tables(0).Rows.Count() - 1
'If TextBox1.Text = ds3.Tables(0).Rows(i)(0) Then
row = foodtable.NewRow
row("PatientID") = ds4.Tables(0).Rows(i)("PatientID")
row("Name") = ds4.Tables(0).Rows(i)("Name")
row("DemandFood") = ds4.Tables(0).Rows(i)("DemandFood")
foodtable.Rows.Add(row)
'DataGrid2.SetDataBindinga(ds2,"DemanfFood)
'End If
Next
ds4.Tables.Add(foodtable)
DataGrid2.SetDataBinding(ds4, "Food")
End Function
With the above coding data could not be retrieve to the datagrid
*datagrid couls br filled if the above codes are placed in a Form_Load or
button_Onclick
vitz... Tag: Sources for threads Tag: 85876
Form in a Control drawing
how i can drawing a Windows Form in a Panel, not on the Dektop.
I will using a Form as Desktop. Tag: Sources for threads Tag: 85875
Migrating from Centura
How do i go about migrating from Centura to DotNet?
--------------------------------
From: Darshan Parekh
-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)
<Id>XCOMKjwr3U6CxtHzPbcYvA==</Id> Tag: Sources for threads Tag: 85874
GIF Images on windows forms
Is it possible to place *.gif images on windows forms in an interlaced
format like a webpage in a way that only image be shown not border or
transparent parts of image.
now i have a form in a VB.NET project and a bird image (bird.gif). the form
taransparency is set to true but my image is shown with border and
transparent parts of image are shown in white color.
i appreciate for any codes or guidances.
Best wishes... Tag: Sources for threads Tag: 85872
prevent scaling of child controls
Hi
I have a form that I need to programmatically resize at runtime. The form is
not user resizable so that's one less problem to take care off, but still
I'm having some problems:
I have a picturebox, which determines the size of the form. Its initial size
doesn't matter, but upon loading the form, I load an image which determines
the size of the picturebox, and thus the entire form (it also has a slider
and a few buttons). I know the relative sizes of each GUI element with
respect to that picturebox - the problem is that I can't set the .Size of
any element so I have to call scale, and calling scale on the form scales
all child controls, including some that should not be scaled (buttons). I
tried putting the controls I don't want to be resized into a panel and set
its Locked property to true, but that doesn't prevent the panel elements
from being resized. So I'm wondering, is there a better way than scaling the
form, then scaling child elements back to have the size I actually want them
to have? Is there a way to make scale only scale the form and none of the
associated controls so that after resizing the form I could call scale on
the controls that I need to resize?
Regards
Stephan Tag: Sources for threads Tag: 85866
Backgroundimage- I can't set it back to 'no image'
In my windows form backgroundimage property setting, once I selected an
image, I can't revert back to it's default setting of no background image.
Everytime I click on that property it brings up the dialog box to select an
image. I don't want to select another background image, I just want an
option to set it back to 'None'. Has anyone else run into this? Thank you
for any ideas. -greg Tag: Sources for threads Tag: 85862
Scrolling in ListView
Hi!
I'm looking for a way to maintain the scrolling ability of a listView during
a drag&drop operation (necessary if the screen is too small to display all
the items of the lv), pretty much like the Windows Explorer does it - when
you hit the upper edge of the window it scrolls upwards.
By the way the AutoScroll property of my ListView is set to true.
Thanks already in advance! Tag: Sources for threads Tag: 85851
DataGrid OnPaint/? -How Do I Draw A GDI Type Circle On Top Of A DataGrid
This is a multi-part message in MIME format.
------=_NextPart_000_0008_01C53229.F8AA1070
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
I want to put a GDI type circle on top of my DataGrid (actually I want =
to put GDI colored border around the entire selected row, but if I can =
figure out how to put a circle on top of it I can do the border)=20
=20
My main form uses a MyDataGrid. instance as the folowing code from =
MyDataGrid.cs
=20
public class MyDataGrid : DataGrid
.
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint (e);
}
=20
On my small datagrid it hits this code about a 100 or so times, it seems =
it's painting each cell, headers, etc individually with all that =
TableStyles stuff.
=20
Where in my code would I do the circle painting thing. Or, where in my =
code am I after it finishes with this OnPaint. Is this done in my main =
form, or do I need to do it somewhere in MyDataGrid.cs that it hits =
after it's done with the OnPaint?
=20
=20
------=_NextPart_000_0008_01C53229.F8AA1070
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1491" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT face=3D"Times =
New Roman"=20
size=3D3>I want to put a GDI type circle on top of my DataGrid (actually =
I want to=20
put GDI colored border around the entire selected row, but if =
I can=20
figure out how to put a circle on top of it I can do the border) =
</FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><?xml:namespace =
prefix =3D o ns =3D=20
"urn:schemas-microsoft-com:office:office" /><o:p><FONT face=3D"Times New =
Roman"=20
size=3D3> </FONT></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT face=3D"Times =
New Roman"=20
size=3D3>My main form uses a MyDataGrid. instance as the folowing code =
from=20
MyDataGrid.cs</FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><o:p><FONT =
face=3D"Times New Roman"=20
size=3D3> </FONT></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT face=3D"Times =
New Roman"=20
size=3D3>public class MyDataGrid : DataGrid</FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT size=3D3><FONT=20
face=3D"Times New Roman">=85<o:p></o:p></FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT size=3D3><FONT=20
face=3D"Times New Roman">protected override void OnPaint(PaintEventArgs=20
e)<o:p></o:p></FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT size=3D3><FONT=20
face=3D"Times New Roman">{<o:p></o:p></FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT size=3D3><FONT=20
face=3D"Times New Roman"><SPAN style=3D"mso-spacerun: =
yes"> =20
</SPAN>base.OnPaint (e);<o:p></o:p></FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT size=3D3><FONT=20
face=3D"Times New Roman">}<o:p></o:p></FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><o:p><FONT =
face=3D"Times New Roman"=20
size=3D3> </FONT></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT face=3D"Times =
New Roman"=20
size=3D3>On my small datagrid it hits this code about a 100 or so times, =
it seems=20
it=92s painting each cell, headers, etc individually with all that =
TableStyles=20
stuff.</FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><o:p><FONT =
face=3D"Times New Roman"=20
size=3D3> </FONT></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT face=3D"Times =
New Roman"=20
size=3D3>Where in my code would I do the circle painting thing. Or, =
where in my=20
code am I after it finishes with this OnPaint. Is this done in my =
main=20
form, or do I need to do it somewhere in MyDataGrid.cs that it hits =
after=20
it=92s done with the OnPaint?</FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><o:p><FONT =
face=3D"Times New Roman"=20
size=3D3> </FONT></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><o:p><FONT =
face=3D"Times New Roman"=20
size=3D3> </FONT></o:p></P></FONT></DIV></BODY></HTML>
------=_NextPart_000_0008_01C53229.F8AA1070-- Tag: Sources for threads Tag: 85849
Hi all,
Does anybody know where I can find some good examples of using threads in
c#.net windows applications?