|
If you have a location X and Y, how do you move a control from where it is on a windows form to the location x and y?
Something like
mycontrol.Move(x, y); ???
thanks
|
|
|
|
|
Try this:
mycontrol.Location = new Point(x, y);
|
|
|
|
|
thank you
that was simple and elegant
|
|
|
|
|
Please can u help on this.
I have a one dataset contains the one datatable. I want pass this datatable as parameter to the storedprocedure because we have one datatype i.e table.
is it possible?if so can u help me on this.
p.v.babu
|
|
|
|
|
I don't think there is an easy way. One article here on CP shows how to use an image data type to pass through an array, but I found that a bit complex.
This KB article though on HOW TO: Perform Bulk Updates and Inserts Using OpenXML with .NET Providers in Visual C++ .NET was brilliantly helpful to me. I had to pass through a huge DataTable array to a SP, and it worked like a bomb.
regards,
Paul Watson
Bluegrass
South Africa
Miszou wrote:
I have read the entire internet. on how boring his day was.
Crikey! ain't life grand?
|
|
|
|
|
Hi,
How to launch an external programm from the application, like the C commanc System ("filename") would do ?
Regards,
Matthieu
|
|
|
|
|
System.Diagnostics.Process.Start("filename", "arguments");
|
|
|
|
|
Is there a way to change the background color of a single character (or
maybe even a larger selection) in a RichTextBox?
|
|
|
|
|
|
Hey! I already answered this.
The graveyards are filled with indispensible men.
|
|
|
|
|
Hello!
I would like to know how to beautify the Progress Bar? e.g. use gradient color or image for the progression index. Any sample coding here?
fm Softair
|
|
|
|
|
Owner-draw it yourself. The ProgressBar in .NET is actually a wrapper class for a progress bar common control in Windows. There's only so much you can do with it before it's easier to do your own.
It's not hard, though. It's just (usually) a rectangle with a certain drawing region that's a percentage, such as value / max + min . There were some great articles by a certain person that went commercial and took all his articles with him...and after he used CP to help beta-test his code.
So, you can either P/Invoke code and try to override the functionality afforded by Windows for the ProgressBar wrapper, or just write your own. Again, it isn't hard. You can use the ControlPaint class to assist (i.e., do all the work) in drawing the correct 3D borders for a rectangle and draw whatever you like in the client area inside the borders (if you want borders, that is). Just use some similar functionality as the progress bar, which is basically a min, max, and value property, and a step method to increment the value (or use value++ and have the property's setter force a repaint). The OnPaint override should do all the drawing (using the ControlPaint for borders, and using the current min, max, and value properties to correctly draw the progress meter). You should also use Control.SetStyle to set the AllPaintingInWmPaint , UserPaint , DoubleBuffer , ResizeRedraw , and Opaque ControlStyles since you'll be handling all the drawing yourself.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hello!
I would like to beautify my menuitem for the SystemTray Example, does it possible? But it always show "int numOldMenu = myMenu.Count;" has problem? Why?
The coding of SystemTrayExample is listed as following:
using System;
using System.Drawing;
using System.Resources;
using System.ComponentModel;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Threading ;
using Utility.NiceMenu;
namespace Demo
{
public class SystemTray : System.Windows.Forms.Form
{
private System.Windows.Forms.NotifyIcon WSNotifyIcon;
private System.ComponentModel.IContainer components;
private Icon mDirIcon = new Icon(typeof(SystemTray).Assembly.GetManifestResourceStream("SystemTrayExample.FLGUSA02.ICO"));
//private NiceMenu myMenu ;
public SystemTray()
{
//constructor for the form
InitializeComponent();
//keep the form hidden
this.Hide();
//OnMyMenu();
//InitializeNotifyIcon();
NiceMenu myNiceMenu = new NiceMenu();
myNiceMenu.UpdateMenu (this.ContextMenu ,new NiceMenuClickEvent (InitializeNotifyIcon));
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.WSNotifyIcon = new System.Windows.Forms.NotifyIcon(this.components);
//
// WSNotifyIcon
//
this.WSNotifyIcon.Text = "";
this.WSNotifyIcon.Visible = true;
//this.WSNotifyIcon.MouseDown += new System.Windows.Forms.MouseEventHandler(this.WSNotifyIcon_MouseDown);
//
// SystemTray
//
this.AccessibleRole = System.Windows.Forms.AccessibleRole.None;
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(8, 7);
this.ControlBox = false;
this.Enabled = false;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "SystemTray";
this.Opacity = 0;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new SystemTray());
}
public void ExitControlForm(object sender, EventArgs e)
{
//Hide the NotifyIcon.
WSNotifyIcon.Visible=false;
this.Close();
}
//private void InitializeNotifyIcon()
private void InitializeNotifyIcon(object sender, System.EventArgs e)
{
//setup the Icon
NotifyIcon WSNotifyIcon = new NotifyIcon();
WSNotifyIcon.Icon = mDirIcon;
WSNotifyIcon.Text = "System Tray Example";
WSNotifyIcon.Visible = true;
//Create the submenus - any number will do
MenuItem[] subMnuItems1 = new MenuItem[3];
subMnuItems1[0] = new MenuItem("Submenu 1", new EventHandler(this.ExitControlForm));
subMnuItems1[1] = new MenuItem("Submenu 2", new EventHandler(this.ExitControlForm));
subMnuItems1[2] = new MenuItem("Submenu 3", new EventHandler(this.ExitControlForm));
//Create the MenuItem objects and add them to
//the context menu of the NotifyIcon.
MenuItem[] mnuItems = new MenuItem[3];
//create the menu items array
mnuItems[0] = new MenuItem("Sub Menu Items");
mnuItems[0].MenuItems.AddRange(subMnuItems1);
mnuItems[0].DefaultItem=true;
mnuItems[1] = new MenuItem("-");
mnuItems[2] = new MenuItem("Exit", new EventHandler(this.ExitControlForm));
//add the menu items to the context menu of the NotifyIcon
ContextMenu notifyIconMenu = new ContextMenu(mnuItems);
WSNotifyIcon.ContextMenu=notifyIconMenu;
}
}
}
fm Softair
|
|
|
|
|
To what "problems" are you referring? Specifics are important. If an exception is being thrown, what exception is it and what is its message?
Also, please post only relevent code to the forums.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
i was wondering if anyone could give me some good information on shell programming...im intrested in tieing my C# program into the right click menu. i want it to be easily uninstallable (like winzip does) any ideas or suggestions ?
Jesse M
The Code Project Is Your Friend...
|
|
|
|
|
Best suggestion - don't use C#. Until "Longhorn" is released, the OS is still written in C/C++. Besides, if you use a .NET language like C#, you're going to have to redefine a lot of shell interfaces that you'll need like IShellExtInit , IContextMenu , and IDataObject (not the one in .NET's BCL) as well as a lot of structures like HMENU , ITEMIDLIST . You'll spend more time redefining everything that's easy to get through headers in C/C++ than writing your functionality, but go for it if you like doing such things.
And if you didn't catch it, there's the list of interfaces you'll need: IShellExtInit and IContextMenu .
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I was wondering. Is alot of long horn wrote in C# or with .net in mind ? Also when is it supposed to come out ? Thanks alot for your comments.
Jesse M
The Code Project Is Your Friend...
|
|
|
|
|
Any good ideas?
Slickman
|
|
|
|
|
I thought I remembered seeing a starter kit on www.asp.net[^]
|
|
|
|
|
The Community starter kit at http://www.asp.net/Default.aspx?tabindex=9&tabid=47[^] offers some ideas on all kinds of stuff including discussion boards. You could also look in the asp.net controls section here http://www.asp.net/ControlGallery/default.aspx?Category=34&tabindex=2[^] for forum controls.
If you decided to build your own, a simple design could include a table for Forums, one for Topics, and one for Comments with one-to-many relationships between each (many Topics to one Forum, many Comments to one Topic). It would be pretty standard C# data access code to select/insert data to/from the tables, and a DataGrid or Repeater control would work nicely for display in an ASP.NET page.
Then get more sophisticated by adding user logins...
All in all, this isn't a bad type of project if you're learning C#.
|
|
|
|
|
Anyone know how to get a cusor to load from an array of bytes? I have a byte[] in a resorce file that is a custom cursor. I need to load a System.Windows.Forms.Cursor from it. I don't have to use a resource file for it, but it needs to be embeded in the exe some how and not on disk. Thanks in advance.
|
|
|
|
|
It's easier if you don't embed it in a ResX file. Instead, add the .cur file to your project and change it's Build Action (in the properties displayed when you click on the file) to "Embedded Resource".
To get the Cursor (Icons work this way, too), either use Assembly.GetManifestResourceStream or - easier - use this particular Cursor constructor:
Cursor cur = new Cursor(typeof(SomeClass), "MyCursor.cur"); ...where SomeClass is a Type that scopes the resource (provides both the assembly reference and the namespace to find the embedded resource by name). For more information, see the aforementioned constructor.
Basically, if SomeClass exists in the namespace MyCompany.MyProject , the example would look for an embedded resource named "MyCompany.MyProject.MyCursor.cur".
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks Heath. I ended up doing it this way. I added it to the project and used a resourcemanager to pull it out. It works great this way. Resources are one spot in .net that I find lacking. MS didn't even provide a good resource editor. All I can find on the net don't work with custom cursors. I had one that was an adding for vs02 but lost it and can't find it again. It worked great.
|
|
|
|
|
Why did you use the ResourceManager ? You simply grab the manifest resource stream. The ResourceManager is for ResX files.
VS.NET has a great resource editor, far better than VS6. It still handles cursors, icons, and bitmaps internally. Instead of string resources, you're supposed to use ResX files. The great thing is that you can embed any file as an embedded resource. If you right-click, you can select "Open with..." to open ANY resource with ANY program (and keep a cached list of programs you use). In VS6, if the resource wasn't understood / handled by the IDE, you had to export the resource, browse to it and open it with the associated application (or open the application then open the file). That was a pain.
In any case, 'tis far easier to just embed the .cur file as an embedded resource and use the Cursor constructor I mentioned, not the ResourceManager . Besides, binary files are stored as bse64 encodings by default. The ResourceManager has overhead for setting things up, then has to find the resource and decode it. The other way is quick and is closer to how it would be done in Win32 when loading a cursor from a persistent file.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Do someone know where can i find the source code of Sqrt() method or where can i read some theory about this subject
thanks for help
|
|
|
|