|
if you are trying to accept only numeric values in your text box, you can use the e.Handle = true of KeyPressEventArgs to cancel the keypress event.
You can try the code below.
string strnum = "0123456789";
if (strnum.IndexOf(e.KeyChar.ToString())<0)
{
e.Handled = true;
}
|
|
|
|
|
i m working with InternetExplrer for that i m using ShDocVw.dll.following coding is used to get the reference to currently opened browsers. what i m doing is putting the entry of brower in listbox.for e.g suppose i write www.yahoo.com in address bar then i put www.yahoo.com in listbox. in the following code ie.LicationURL return the website name in my case www.yahoo.com as i mentioned above. what i did is put all th entries of opened browser into the listbox.when i click on any of the URL in list box . what would i like [b]shows that browser on TOp of all other browser.[/b] for that i used the following coding...
foreach (SHDocVw.InternetExplorer ie in shellWindows)
{
string filnam = Path.GetFileNameWithoutExtension(ie.FullName).ToLower();
if (filnam.Equals("iexplore"))
{
if(this.listBox1.SelectedItem.ToString().Equals(ie.LocationURL))
{
MessageBox.show(ie.LocationURL.ToString());
// what code should be here to put the browser on top
}
}
}
Above mentioned code is working fine but is not giving desired ouput
Amit Grover
CDAC R&D
|
|
|
|
|
Can anyone tell me how, if it is possible, to pass a method as an argument for another method?
|
|
|
|
|
Hello,
Firstly define method type:
public delegate int TypeName([Type arg[,[Type arg,...]]]);
This is your method type.
Now define one object of this type
private TypeName myObject;
& also define one method which has declaration as your method type
Note: Object & method are different so use different names for them.
Now initialize object
myObject = new TypeName(MethodName);
now you can pass this object as argument & use same methodtype for calling method for that argument.
Divyang Mithaiwala
with best regards
|
|
|
|
|
Thank you Divyang Mithaiwala, very much appreciated.
|
|
|
|
|
Use a delegate:
class A
{
public delegate void SomeDelegate();
public void MethodWithDelegateParam(SomeDelegate del)
{
del();
}
}
and in client code:
class B
{
public void MyMethod()
{
DoSomething();
}
public static void Main()
{
B b = new B();
A a = new A();
a.MethodWithDelegateParam(new A.SomeDelegate(b.MyMethod));
}
}
[^] For more information.
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
Thank you Michel Prévost, very much appreciated.
|
|
|
|
|
I am working on a web browser project, i have done the work as when new tab button is clicked, a new tab is created with a browser, but the navigation occurs only in the first tab browser. Is there any way to correct it?
|
|
|
|
|
I don't have the detail of your project and what technology you are using to achieve the display of HTML, but I suspect that you don't keep track of the currently active tab page. What I suggest is that you have a private variable that keeps track of all the tab pages (a collection, for instance) and another one to keep track of the current tab page index. When the user creates a new tab, update your variables accordingly.
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
I am working with C#.NET windows application & using the explorer given in the tools to navigate.
|
|
|
|
|
I keep getting the above message on a C# program.
What assembly/namespace have I missed?
|
|
|
|
|
If you had checked the documentation for the DescriptionAttribute class, you would have seen that it's in the System.ComponentModel namespace.
---
b { font-weight: normal; }
|
|
|
|
|
Hi,
I would please like anyone's help. I need to convert any .PDF file into a .EMF. Enhanced Meta File. The reason being is so that I can edit and manipulate this PDF's data. I need something this is preferably free and code available.
Any help will be greatly appreciated. Tks
-- modified at 3:20 Friday 20th January, 2006
|
|
|
|
|
I wrote a small web application that will be used by few people. I would like to write a small program to install it to different computers. I am very new in this industry so any idea how I can do that
|
|
|
|
|
A WEB application? You can still create an installer, but the app is installed to the IIS Server, not the clients.
All you do is add a Setup project to your Solution. Right-click the Solution in the Solution Explorer, select Add New Item. Under "Other Project Types", you'll find Setup and Deployment. Setup Wizard would be a good one to pick for your first time doing this.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks for replying.
I did just that and the options I get when I select Add New Item doesn't
give me the option "Other Project Types". I right clicked on the solution.
Is there anything I am doing wrong
|
|
|
|
|
You have to right-click the very top line of the Solution Explorer. Add, Add New Item, then you'll see either a Other Project Types or Setup and Deployment or both.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks it works perfectly
|
|
|
|
|
I'm getting some problem to bind my DropDown control with an xml file...
I made an example using xmlTextReader displaying it in a table format. its working...
But i need to display data in my dropdown control using xmlTextReader....
please help....
here is my example coding...
private void Page_Load(object sender, System.EventArgs e)
{
// Placer ici le code utilisateur pour initialiser la page
string strAtt,strType,strName,strValue,strTemp,strPath;
strPath=Server.MapPath("list.xml");
System.Xml.XmlTextReader xmlRdr;
xmlRdr=new
System.Xml.XmlTextReader(strPath);
strTemp="<table border=1 width=100%><tr><th width=150px>ISBN No.</th><th>Book Name</th></tr>";
Response.Write(strTemp);
while(xmlRdr.Read())
{strType=Convert.ToString(xmlRdr.NodeType);
strName=xmlRdr.Name;
if(strType=="Element")
{
if(strName=="subject")
{
strAtt=xmlRdr.GetAttribute("name");
strTemp="<tr><td colspan=2 align='left' bgcolor='pink'>"+strAtt+"</td></tr>";
Response.Write(strTemp);}
else if(strName=="book")
{
strAtt=xmlRdr.GetAttribute("isbn");
xmlRdr.Read();
strValue=xmlRdr.Value;
strTemp="<tr><td>"+strAtt+"</td><td>"+strValue+"</td></tr>";
Response.Write(strTemp);
}
}
}
Response.Write("</table>");
xmlRdr.Close();
}
and now how will i change this code to display in a dropdown control????
-- modified at 3:07 Friday 20th January, 2006
|
|
|
|
|
Hi all,
How can i add a user control as a treenode to a TreeView control using C#.
What are all the steps that i need to take in order to accomplish the above task?
Any examples or links will be helpful.
Thanks in Advance
Phani Kiran K.
|
|
|
|
|
Hi, I have created the following program first as a console application. I have used the printData() method to output the data of an instance of a Person or Athlete class. I want to create a label and show the data in a label. When I try to create a label, or any similar control, that control isn't seen in the TestClasses class, and the Athlete. It is seen only in the Person constructors. Any help would be appreciated.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace windowsPracticingWithClasses
{
///
/// Summary description for Form1.
///
public class Person : System.Windows.Forms.Form
{
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
//My instance variables
private string firstName, lastName;
private int age;
private double height, weight;
private string bankName;
private double bankAccount;
private double balance = 0;
private string squareColor;
# region Properties
//Properties
public string FirstName
{
get { return firstName; }
set { firstName = value; }
}
public string LastName
{
get { return lastName; }
set { lastName = value; }
}
public int Age
{
get { return age; }
set { age = value; }
}
public double Height1
{
get { return height; }
set { height = value; }
}
public double Weight
{
get { return weight; }
set { weight = value; }
}
public string BankName
{
get { return bankName; }
set { bankName = value; }
}
public double BankAccount
{
get { return bankAccount; }
set { bankAccount = value; }
}
public double Balance
{
get { return balance ; }
set { balance = value; }
}
public string SquareColor
{
get { return squareColor ; }
set { squareColor = value; }
}
# endregion
//Custom constructor
public Person(int age, double height, double weight, string bankName, double bankAccount, double balance)
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
this.age = age;
this.height = height;
this.weight = weight;
this.bankName = bankName;
this.bankAccount = bankAccount;
this.balance = balance;
}
//Default constructor
public Person()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
}
#region My Methods
//My Methods
public void makeDeposit(int amount)
{
balance+= amount;
}
public void makeWithdrawal(int amount)
{
balance-= amount;
}
public virtual void printData()
{
Console.WriteLine("\nProfile: \n\nAge: " + this.age);
Console.WriteLine("Height: " + this.height);
Console.WriteLine("Weight: " + this.weight);
Console.WriteLine("Bank Name: " + this.bankName);
Console.WriteLine("Bank Account: " + this.bankAccount);
Console.WriteLine("Balance: " + this.balance);
}
#endregion
///
/// 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()
{
//
// Person
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Name = "Person";
this.Text = "Form1";
}
#endregion
}
class Athlete : Person
{
public string sport;
public Athlete(string sport) : base(23,5.6,120,"Chase",5671234,1000)
{
this.sport = sport;
}
public override void printData()
{
base.printData();
Console.WriteLine("Sport Practicing: " + this.sport);
}
};
class TestClasses
{
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new Person());
Person[] person = new Person[5];
person[0] = new Person(22,5.6,120,"Chase",5671234,2000);
person[0].printData();
Person[] athlete = new Athlete[3];
athlete[0] = new Athlete("Figure Skating");
athlete[0].FirstName = "Sarah";
athlete[0].LastName = "Hughes";
athlete[0].Age = 20;
athlete[0].Height1 = 5.5;
athlete[0].Weight = 120;
athlete[0].BankName = "Chase";
athlete[0].BankAccount = 434324;
athlete[0].Balance = 200;
athlete[1] = new Athlete("Martial Arts");
athlete[1].FirstName = "Kim";
athlete[1].LastName = "Chung";
athlete[1].Age = 21;
athlete[1].Height1 = 5.7;
athlete[1].Weight = 130;
athlete[1].BankName = "Citi";
athlete[1].BankAccount = 212312;
athlete[1].Balance = 300;
athlete[2] = new Athlete("Soccer");
athlete[2].FirstName = "Joe";
athlete[2].LastName = "Tribiani";
athlete[2].Age = 22;
athlete[2].Height1 = 5.6;
athlete[2].Weight = 140;
athlete[2].BankName = "Apple";
athlete[2].BankAccount = 123124;
athlete[2].Balance = 400;
for(int i = 0; i < athlete.Length ; i++)
{
athlete[i].printData();
}
Console.ReadLine();
}
}
}
|
|
|
|
|
Hi!
I'm not completely sure if I've understood your problem, but it seems to be an attribute visibility question.
You should learn about the differences between private, protected, internal, public (from MSDN, for example[^]), then the solution will dawn on you...
Regards,
mav
|
|
|
|
|
Hi, thanks for the response. Basically I have a base class Person and a child Class Athlete. In the main function I have created an instance like the Person[] athlete = new Athlete[3]; and populated it. Then I call the printData function. In console application there was no problem to see the output as follows:
for(int i = 0; i < athlete.Length ; i++)
{
athlete[i].printData();
}
How can I do the same but now to see the output in a label?
Thanks alot.
|
|
|
|
|
How can I keep a form deactivated and still accept text input? By setting the WS_EX_NOACTIVATE flag, I can put a form in background and receive mouse hit. But textbox can't accept any key.
Best Rgds.
Martin
|
|
|
|
|
No it can't. Deactivating the form prevents the input focus from being moved to it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|