|
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.
|
|
|
|
|
You have almost everything, but you have to add a couple of things:
1. You must provide definition for the MyCustomEventArgs (look at my previous exmple)
2. Define click event method for buttonNew button, and in this method call :
private void buttonNew_Click(object sender, System.EventArgs se)
{
if(NewRecord != null)
NewRecord(this, new MyCustomEventArgs());
}
3. According to me, it would be better to remove the delegate outside the class definition ( place it simply in dabir namespace )
4. Finally in your form where you are using your custom control register the appropriate method with similar signature as the delegate have.
//ArrowControl definition
ArrowControl ctrl = new ArrowControl();
//Form construktor
public MyForm()
{
ctrl.NewRecord += new MyControEventHandeler(NewRecordHandler);
}
public void NewRecordHandler(object sender, MyCustomEventArgs e)
{
// do appropriate things with new record
}
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 Tomas:
As I guess, my problem is in UserControl! so if I make it clear the rest will be ok (i hope ) I told u where is my problems.
So, Could u plz do it for me (u have my code) or tell me more, it might be rude but im really sorry
Please...I'll be thankful.
lookig to hear from u ASAP!
Always, Hovik.
|
|
|
|
|
Dear freind:
I add ur code to UserContol but it gives me error for not defined namespace.
These r my errors:
The type or namespace name 'MyContolEvent' could not be found<br />
The type or namespace name 'MyCustomEventArgs' could not be found<br />
The type or namespace name 'SystemEventArgs' could not be found
Please help me to figure it out!
Im looking to hear from u ASAP
Always,
Hovik.
|
|
|
|
|
OK, this is some typos
SystemEventArgs shoud be System.EventArgs ( sorry for that)
the declaration public event MyControlEvent ModeChanged; should be public event MyControlEventHandler ModeChanged;
Sorry, my fingers are quicker than my brain
T.
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
|
|
|
|
|
Ok Tomas:
Third problem has gone but the rest still are breathing!!!
Please HELP?!?! What shoudl I do?!?!?
Always, Hovik.
|
|
|
|
|
Ive done that but with no delegate! maybe simpler way but I would like to share it if its good or not!?!
I made the buttoms declaration in UserControl as public & define a click event for them from from!
how is that?! good job?! or ... ?
I just wanna do something fine not just go on
Always[ ],
Hovik Melkomian.
|
|
|
|
|
Does someone knows how to retrieve product key for Windows or Office? Something like Magical Jelly Bean Keyfinder I mean.
Thanks to all of you.
|
|
|
|
|
Why would you want to, in training to be a hacker?
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
) No, not a hacker. I'm IT manager in a company with 270 workstation and I need to solve the licenses problem, being a mess. I want to make a database with hardware components, obtained through WMI (done) and licenses.
Thanks to all of you.
|
|
|
|
|
How do you read and write from the resource file?(Form1.resx in my case)
Thanks!
"To teach is to learn twice"
|
|
|
|
|
I wanted to try out using System.Management
but the compiler (I tried sharp-developer and Borland
c# builder) says that System.Management is undeclared.
What do I have to do, to make System.Management known?
Other namespaces, like System.IO, System.Net are available,
and I could compile and run programs using them.
I installed .NET 1.1 completely from the archive that
is about 100MB in size / os is Windows XP.
I found on the web, that XP should have WMI installed already.
Thanks !!
|
|
|
|
|
thank you, add reference did help!
|
|
|
|
|
hi, i overrided a method of the parent class. i want to invoke the overrided method in parent class. any keyword for this?
super? or what?
i am newbie in C#
thanks,
jim
|
|
|
|
|
|
well to call a base class as in java
Form1
super("My first form");
would be in c#
From1
base("my form"); // or whetever arguments are expected
if its a contructor
public Form1 () : base ("")
{}
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
if (!System.IO.Directory.Exists(FolderPath))
System.IO.Directory.CreateDirectory(FolderPath);
FolderPath is a string containing the full path of the folder in question, like @"C:\ThisFolder".
Hope that helps...
|
|
|
|
|
Who're you helping anyway???
Nick Seng (the programmer formerly known as Notorious SMC)
God, I pity me! - Phoncible P. Bone
|
|
|
|
|
hi,
are there any tools available that can able to view the method, property of a .net dll?
i don't know but i think it is quite simple tools that should available in VS.NET. i can't find it.
thanks,
jim
|
|
|
|
|
Reflector[^] is the best tool out there for doing this right now.
-Nick Parker
|
|
|
|
|
|
How can I capture all inbound and outbound traffic from a computer? I remember seeing a few projects such as MyDUMeter(http://www.codetools.com/useritems/MyDUMeter.asp), but I would like to block certain packets being sent or received on various ports.
Any help would be greatly appreciatedly thank you.
|
|
|
|
|
I must be going mental or something because I can't for the life of me get one form to center on top of another. It seems to me that this code should work, but it doesn't.
this.Top = (this.Owner.Height / 2) - this.Height;
this.Left = (this.Owner.Width / 2) + this.Width; but it never centers the form. What am I doing wrong here?
- monrobot13
|
|
|
|
|
Your formula is wrong... Try this:
this.Top = (this.Owner.Height - this.Height) / 2;
this.Left = (this.Owner.Width - this.Width) / 2;
|
|
|
|
|
actually you should set the Location property. the top and left are old vb'er ways
plus the form property has a center option property
|
|
|
|
|