|
Assuming you are using Visual Studio.NET, open the solution explorer and right click on the "references" folder, select the "Add reference" menu choice, then click the browse button. Browse to your .DLL file, and click "OK". That will add a reference to your .DLL to the project. From there, just add a line at the top of your source file like this:
"using mynamespace;"
Martin Cook
Who needs cyberspace when you have CP space?
|
|
|
|
|
Thank you , .. as for .NET classes, they should automatically reference .. is this correct?
I had a problem where I created an app that would not run on another system which didn't have VS.NET installed.
It was an XP Pro box with .NET1.1 installed.
|
|
|
|
|
I had a problem where I created an app that would not run on another system which didn't have VS.NET installed.
As long as the target machine has the .NET framework installed, you should be good to go. Ensure that the framework version on the target machine is the same as the one you compiled your application to.
|
|
|
|
|
Hey,
How do you hide a form on startup so that it doesn't show at all. I want to hide a form initially until the user clicks on a notifyIcon. Currently...
public Form1()
{
InitializeComponent();
this.Hide();
}
...does not work. Any suggestions?
-- Adam
"If you can't beat your computer in chess, try kickboxing"
|
|
|
|
|
Hey Adam,
try this, to prevent the form to be created at startup, if the no-button is clicked.
if (MessageBox.Show("Start Application",
"Question",
MessageBoxButtons.YesNo,
MessageBoxIcon.Information) == DialogResult.Yes)
{
Application.Run(new Form1());
}
Maybe it's helpful...
Jörg
|
|
|
|
|
why not set a madule main function to be startup rather than a form. then you can do what you want with it
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
Okay,
I've got a semi working solution, tell me if i'm doing anything that could lead to problems later.
public class Class1
{
static void Main()
{
Form1 form = new Form1();
Application.Run();
}
}
public class Form1 : System.Windows.Form
{
public Form1()
{
IntiallizeComponent();
this.Visible = false;
}
}
This creates the notifyIcon in the system tray, but does not show the form. When the notifyIcon is double clicked, then the form pops up. When the form is disposed, i have it call Application.Exit() so that the Application quits properly...this is mostly what i'm concerned about, that the tread is terminating properly.
-- Adam
"If you can't beat your computer in chess, try kickboxing"
|
|
|
|
|
I have a window with AutoScroll set to true, but I seem to have some odd problem wtih it.
Whenever the window gets focus, the scrollbars jump to 0. How can I fix this?
|
|
|
|
|
There is a property called AutoScrollPosition which contains the offset of the scrollwindow. I guess you have to manually account for this all the time...
But I really don't know cause I have the same problem.
If you find a good solution please let me know...
|
|
|
|
|
Hi guys !
Is there a way to know on which column of a ListView control the user has clicked ?
We can now the row but not the column.
Any idea ?
Thanks.
|
|
|
|
|
aeros,
you can do it through OnMouseDown (or OnMouseUp). That events have MouseEventArgs parameters X, Y which you can use in ListView GetItemAt method. GetItemAt gives you the clicked ListViewItem. And thanks to Index property you can obtain the column.
Hope it helped.
Tomas Rampas
------------------------------
gedas CR s.r.o.
System analyst, MCP
TGM 840,
293 01 Mlada Boleslav,
Czech Republic
Telefon/phone +420(326)711411
Telefax/fax +420(326)711420
rampas@gedas.cz
http://www.gedas.com/
------------------------------
|
|
|
|
|
Hi,
It doesn't work because ListViewItem.Index property gives you the row not the column.
--
Regards,
Julian.
|
|
|
|
|
 You are right. We have to help ourselves with interop:
class YourClassName<br />
{<br />
const int LVM_FIRST = 0x1000;<br />
const int LVM_GETSUBITEMRECT = (LVM_FIRST + 56);<br />
const int LVIR_BOUNDS = 0;<br />
const int LVIR_ICON = 1;<br />
<br />
[StructLayout(LayoutKind.Sequential)]<br />
struct RECT<br />
{<br />
public int left;<br />
public int top;<br />
public int right;<br />
public int bottom;<br />
};<br />
[DllImport("user32.dll")]<br />
private static extern int SendMessage(IntPtr hWnd, int wMsg, int wParam, ref RECT lParam );<br />
<br />
private void listView1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)<br />
{<br />
RECT myrect;<br />
ListViewItem lvitem = listView1.FocusedItem;<br />
int wParam = lvitem.Index;<br />
int intLVSubItemIndex;<br />
ListViewItem.ListViewSubItem LVSubItem = null;<br />
int intSendMessage;<br />
<br />
for( intLVSubItemIndex = 1; intLVSubItemIndex < lvitem.SubItems.Count; intLVSubItemIndex++)<br />
{<br />
LVSubItem = lvitem.SubItems[intLVSubItemIndex];<br />
myrect = new RECT();<br />
myrect.top = intLVSubItemIndex;<br />
myrect.left = LVIR_BOUNDS;<br />
intSendMessage = SendMessage(listView1.Handle, LVM_GETSUBITEMRECT, wParam, ref myrect);<br />
if( e.X < myrect.left)<br />
{<br />
LVSubItem = lvitem.SubItems[0];<br />
intLVSubItemIndex = 0;<br />
break;<br />
}<br />
else if(e.X >= myrect.left && e.X <= myrect.right)<br />
{<br />
break;<br />
}<br />
else<br />
LVSubItem = null;<br />
}<br />
<br />
if (LVSubItem != null && lvitem != null)<br />
{<br />
MessageBox.Show(String.Format("ColumnIndex: {0} {1}", intLVSubItemIndex,<br />
LVSubItem.Text));<br />
}<br />
<br />
<br />
}<br />
}<br />
In the intLVSubItemIndex you have 0 base index of clicked column.
Tomas Rampas
------------------------------
gedas CR s.r.o.
System analyst, MCP
TGM 840,
293 01 Mlada Boleslav,
Czech Republic
Telefon/phone +420(326)711411
Telefax/fax +420(326)711420
rampas@gedas.cz
http://www.gedas.com/
------------------------------
To be or not to be is true...
George Bool
|
|
|
|
|
I have a little problem...
I have a panel with controls on it, that i want to draw to the printer. the controls consist of smaller panels with text inside them, and listboxes with lines of text inside as well.
(class diagram editor)
Now the problem is that when I print this i scale it to fit to A4 (or whatever specified) paper size. No problem scaling a simple bounding rectangle to the textboxes and listboxes, but now I want the text to be printed inside these components as well, so the print-out will appear as on screen. How can i fit the text into these boxes, i.e. apply a scaling to the bounding rectangle of the text?
I have thought of two things:
Either change font size until something that fits is found
OR
Draw the text to a bitmap and scale this.
Is there any 'standard' way of doing things like this? Any suggestions?
|
|
|
|
|
I want to change that ListView.ListViewItem's height.
HOW TO ?????
help!!!
|
|
|
|
|
I think you would have override OnPaint method and draw the item for yourself.
Tom.
Tomas Rampas
------------------------------
gedas CR s.r.o.
System analyst, MCP
TGM 840,
293 01 Mlada Boleslav,
Czech Republic
Telefon/phone +420(326)711411
Telefax/fax +420(326)711420
rampas@gedas.cz
http://www.gedas.com/
------------------------------
|
|
|
|
|
Hi all,
does somebody know, how to convert an initialized string into an executeable expression.
Like:
string Form = "Form1.text" + "=" + "Hello";
This string should now be executed directly, instead of
doing
Form1.text = "Hello";
Background is to rename buttons and forms....
Would be very helpful if somebody has a
great Idea.
Thanks
Jörg
|
|
|
|
|
I would use the MS Script Control. I think there's some help on it in the IDE help files
Nick Seng (the programmer formerly known as Notorious SMC)
God, I pity me! - Phoncible P. Bone
|
|
|
|
|
How can I access the functions of a COM object located in a windows service?
The windows service was written under Visual C++ 6.0.
-Alma-
|
|
|
|
|
I have done it in the following way:
1. registered the service: MyService.exe /service
2. added the associated type lib to the project:
using MyServiceLib;
(I used the Add reference wizard: Solution explorer tab, right click on the solution name, click on Add reference..., click on COM tab, in the appearing list box select the needed type library)
3. Created an object:
IMyObject newObject = new MyServiceLib.MyObjectClass();
4. Called the objects methods:
newObject.Function(param1, param2);
-Alma-
|
|
|
|
|
Hi there!
I've made a UserContol for my app. for modifing records in my form! SO i have new, delete & ... buttons in my UserControl but I wanna fire the AddRecord, DeleteRecord & ... functions from my Form! I mean functions are in my form but I want to fire them by clicking UserContol buttons.
How can I do this?!
Any help appreciated!
Always, Hovik.
(forgive my English)
|
|
|
|
|
Hello,
you can Add an custom events and delegates to your UserControl which will be trigged when user clicks button in your UserControl. In your Form you can register delegate method for the UserControl event which will be responsible for event processing.
T.
|
|
|
|
|
Hi there & tnx for ur reply dear:
I know what u told but JUST in Theory!!! can u help me to make it?!?!
A simple sample or some codes will be OK;)
Can u help me?!
tnx again & hope to hear from u ASAP!
Always,
Hovik Melkomian.
|
|
|
|
|
OK, here is the code snippet:
First, in you CustomControl we define an event:
namespace MyControlLibry
{
class MyControl : UserControl
{
public event MyControlEvent ModeChanged;
public MyControl()
{
}
// If user clicked on Insert button it cause trigger new ModeChanged event:
public ButtonInsertClick(object sender, System.EventArgs ea)
{
if (myevent != null)
ModeChanged(this, new MyCustomEventArgs("INSERT"));
}
}
// function prototype
public delgate void MyControlEventHandler(object sender, MyCustomEventArgs mcea);
// custom event args
public class MyCustomEventArgs: SystemEventArgs
{
private string stxt;
public MyCustomEventArgs(string text)
{
stxt = text;
}
public string MyCustomText
{
get { return stxt;}
set { stxt = value;}
}
}
}
Finally in you Form you must define event handler:
public class MyForm : Form
{
private MyControl ctrl;
public MyForm()
{
ctrl.ModeChanged = new MyControlEventHandler(CustomModeChanged);
}
// CustomModeChanged must have the same signature as delegate so
public void CustomModeChanged(object sender, MyCustomEventArgs mea)
{
Console.WriteLine(mea.MyCustomText);
}
}
Hope it helps
Tomas Rampas
------------------------------
gedas CR s.r.o.
System analyst, MCP
TGM 840,
293 01 Mlada Boleslav,
Czech Republic
Telefon/phone +420(326)711411
Telefax/fax +420(326)711420
rampas@gedas.cz
http://www.gedas.com/
------------------------------
To be or not to be is true...
George Bool
|
|
|
|
|
dear friend:
tnx for ur reply indeed, u can think that im silly but I couldn't do it
now im sending my UserContol Code & if its possible tell mo how to do that!?
I'll really be thankfull!
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
namespace Dabir
{
///
/// Summary description for UserControl1.
///
public class ArrowControl : System.Windows.Forms.UserControl
{
private System.Windows.Forms.Panel panel1;
private System.ComponentModel.IContainer components;
private System.Windows.Forms.Button buttonLast;
private System.Windows.Forms.Button buttonNext;
private System.Windows.Forms.Button buttonPrev;
private System.Windows.Forms.Button buttonFirst;
private System.Windows.Forms.ToolTip toolTip;
private System.Windows.Forms.Button buttonNew;
private System.Windows.Forms.Button buttonDelete;
private System.Windows.Forms.Button buttonEdit;
private System.Windows.Forms.Button buttonSearch;
private System.Windows.Forms.Button buttonFilter;
private System.Windows.Forms.Button buttonSort;
private System.Windows.Forms.Button buttonOk;
private System.Windows.Forms.Button buttonCancel;
//My Var
public BindingManagerBase UCBinder;
public DataSet UCDataSet;
public string UCAction;
private bool InEditMode;
//events
public event AddNewRecord NewRecord;
public delegate void MyControEventHandeler(object sender, MyCustomEventArgs mcea);
public ArrowControl()
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
// TODO: Add any initialization after the InitComponent call
InEditMode = false;
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if( components != null )
components.Dispose();
}
base.Dispose( disposing );
}
#region Component 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();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(ArrowControl));
this.panel1 = new System.Windows.Forms.Panel();
this.buttonOk = new System.Windows.Forms.Button();
this.buttonFilter = new System.Windows.Forms.Button();
this.buttonSearch = new System.Windows.Forms.Button();
this.buttonEdit = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonNew = new System.Windows.Forms.Button();
this.buttonFirst = new System.Windows.Forms.Button();
this.buttonPrev = new System.Windows.Forms.Button();
this.buttonNext = new System.Windows.Forms.Button();
this.buttonLast = new System.Windows.Forms.Button();
this.buttonDelete = new System.Windows.Forms.Button();
this.buttonSort = new System.Windows.Forms.Button();
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// panel1
//
this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.panel1.Controls.Add(this.buttonOk);
this.panel1.Controls.Add(this.buttonFilter);
this.panel1.Controls.Add(this.buttonSearch);
this.panel1.Controls.Add(this.buttonEdit);
this.panel1.Controls.Add(this.buttonCancel);
this.panel1.Controls.Add(this.buttonNew);
this.panel1.Controls.Add(this.buttonFirst);
this.panel1.Controls.Add(this.buttonPrev);
this.panel1.Controls.Add(this.buttonNext);
this.panel1.Controls.Add(this.buttonLast);
this.panel1.Controls.Add(this.buttonDelete);
this.panel1.Controls.Add(this.buttonSort);
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
this.panel1.Size = new System.Drawing.Size(248, 88);
this.panel1.TabIndex = 4;
//
// buttonOk
//
this.buttonOk.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("buttonOk.BackgroundImage")));
this.buttonOk.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonOk.Location = new System.Drawing.Point(8, 8);
this.buttonOk.Name = "buttonOk";
this.buttonOk.Size = new System.Drawing.Size(32, 32);
this.buttonOk.TabIndex = 5;
this.toolTip.SetToolTip(this.buttonOk, "تاييد");
//
// buttonFilter
//
this.buttonFilter.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("buttonFilter.BackgroundImage")));
this.buttonFilter.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonFilter.Location = new System.Drawing.Point(208, 48);
this.buttonFilter.Name = "buttonFilter";
this.buttonFilter.Size = new System.Drawing.Size(32, 32);
this.buttonFilter.TabIndex = 6;
this.toolTip.SetToolTip(this.buttonFilter, "فيلتر");
this.buttonFilter.Click += new System.EventHandler(this.buttonFilter_Click);
//
// buttonSearch
//
this.buttonSearch.BackColor = System.Drawing.SystemColors.Control;
this.buttonSearch.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("buttonSearch.BackgroundImage")));
this.buttonSearch.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonSearch.Location = new System.Drawing.Point(8, 48);
this.buttonSearch.Name = "buttonSearch";
this.buttonSearch.Size = new System.Drawing.Size(32, 32);
this.buttonSearch.TabIndex = 11;
this.toolTip.SetToolTip(this.buttonSearch, "جستجو");
//
// buttonEdit
//
this.buttonEdit.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("buttonEdit.BackgroundImage")));
this.buttonEdit.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonEdit.Location = new System.Drawing.Point(48, 48);
this.buttonEdit.Name = "buttonEdit";
this.buttonEdit.Size = new System.Drawing.Size(32, 32);
this.buttonEdit.TabIndex = 10;
this.toolTip.SetToolTip(this.buttonEdit, "ويرايش");
this.buttonEdit.Click += new System.EventHandler(this.buttonEdit_Click);
//
// buttonCancel
//
this.buttonCancel.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("buttonCancel.BackgroundImage")));
this.buttonCancel.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonCancel.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(178)));
this.buttonCancel.Location = new System.Drawing.Point(208, 8);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
this.buttonCancel.Size = new System.Drawing.Size(32, 32);
this.buttonCancel.TabIndex = 0;
this.toolTip.SetToolTip(this.buttonCancel, "برگشت");
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// buttonNew
//
this.buttonNew.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("buttonNew.BackgroundImage")));
this.buttonNew.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonNew.Location = new System.Drawing.Point(88, 48);
this.buttonNew.Name = "buttonNew";
this.buttonNew.Size = new System.Drawing.Size(32, 32);
this.buttonNew.TabIndex = 9;
this.toolTip.SetToolTip(this.buttonNew, "جديد");
//
// buttonFirst
//
this.buttonFirst.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("buttonFirst.BackgroundImage")));
this.buttonFirst.Cursor = System.Windows.Forms.Cursors.Default;
this.buttonFirst.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonFirst.Location = new System.Drawing.Point(48, 8);
this.buttonFirst.Name = "buttonFirst";
this.buttonFirst.Size = new System.Drawing.Size(32, 32);
this.buttonFirst.TabIndex = 4;
this.toolTip.SetToolTip(this.buttonFirst, "رکورد اول");
this.buttonFirst.Click += new System.EventHandler(this.buttonFirst_Click);
//
// buttonPrev
//
this.buttonPrev.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("buttonPrev.BackgroundImage")));
this.buttonPrev.Cursor = System.Windows.Forms.Cursors.Default;
this.buttonPrev.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonPrev.Location = new System.Drawing.Point(88, 8);
this.buttonPrev.Name = "buttonPrev";
this.buttonPrev.Size = new System.Drawing.Size(32, 32);
this.buttonPrev.TabIndex = 3;
this.toolTip.SetToolTip(this.buttonPrev, "رکورد قبلي");
this.buttonPrev.Click += new System.EventHandler(this.buttonPrev_Click);
//
// buttonNext
//
this.buttonNext.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("buttonNext.BackgroundImage")));
this.buttonNext.Cursor = System.Windows.Forms.Cursors.Default;
this.buttonNext.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonNext.Location = new System.Drawing.Point(128, 8);
this.buttonNext.Name = "buttonNext";
this.buttonNext.Size = new System.Drawing.Size(32, 32);
this.buttonNext.TabIndex = 2;
this.toolTip.SetToolTip(this.buttonNext, "رکورد بعدي");
this.buttonNext.Click += new System.EventHandler(this.buttonNext_Click);
//
// buttonLast
//
this.buttonLast.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("buttonLast.BackgroundImage")));
this.buttonLast.Cursor = System.Windows.Forms.Cursors.Default;
this.buttonLast.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonLast.Location = new System.Drawing.Point(168, 8);
this.buttonLast.Name = "buttonLast";
this.buttonLast.Size = new System.Drawing.Size(32, 32);
this.buttonLast.TabIndex = 1;
this.toolTip.SetToolTip(this.buttonLast, "رکورد آخر");
this.buttonLast.Click += new System.EventHandler(this.buttonLast_Click);
//
// buttonDelete
//
this.buttonDelete.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("buttonDelete.BackgroundImage")));
this.buttonDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonDelete.Location = new System.Drawing.Point(128, 48);
this.buttonDelete.Name = "buttonDelete";
this.buttonDelete.Size = new System.Drawing.Size(32, 32);
this.buttonDelete.TabIndex = 8;
this.toolTip.SetToolTip(this.buttonDelete, "حذف");
//
// buttonSort
//
this.buttonSort.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("buttonSort.BackgroundImage")));
this.buttonSort.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonSort.Location = new System.Drawing.Point(168, 48);
this.buttonSort.Name = "buttonSort";
this.buttonSort.Size = new System.Drawing.Size(32, 32);
this.buttonSort.TabIndex = 7;
this.toolTip.SetToolTip(this.buttonSort, "ترتيب");
//
// ArrowControl
//
this.Controls.Add(this.panel1);
this.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(178)));
this.Name = "ArrowControl";
this.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
this.Size = new System.Drawing.Size(248, 88);
this.panel1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void buttonLast_Click(object sender, System.EventArgs e)
{
UCBinder.Position = UCBinder.Count-1;
FirstRec(false);
LastRec(true);
}
private void buttonNext_Click(object sender, System.EventArgs e)
{
if(UCBinder.Position < UCBinder.Count-1)
{
UCBinder.Position++;
LastRec(false);
FirstRec(false);
}
else
LastRec(true);
}
private void buttonPrev_Click(object sender, System.EventArgs e)
{
if(UCBinder.Position > 0)
{
UCBinder.Position--;
FirstRec(false);
LastRec(false);
}
else
FirstRec(true);
}
private void buttonFirst_Click(object sender, System.EventArgs e)
{
UCBinder.Position = 0;
FirstRec(true);
LastRec(false);
}
private void FirstRec(bool able)
{
buttonFirst.Enabled = !able;
buttonPrev.Enabled = !able;
}
private void LastRec(bool able)
{
buttonLast.Enabled = !able;
buttonNext.Enabled = !able;
}
private void buttonCancel_Click(object sender, System.EventArgs e)
{
...
}
private void buttonFilter_Click(object sender, System.EventArgs e)
{
...
}
private void buttonEdit_Click(object sender, System.EventArgs e)
{
...
}
}
}
Always,
Hovik Melkomian.
|
|
|
|
|