|
hi, i am a new guy for c#.
i have some doubts in c#(windows application) , plz help me
The 1st form include Userid, Password and Login button. when i was enter the userid and password it goes to sqlserver2000 database table (login table) then check the userid and password, the userid has been present sucessfully login, then 2nd form shown else fail.
The 2nd form include one label and button(logout)
In 2nd form how i get (1st form userid)userid for lable.
plz send sampl code....it was very urgent...
by
prabu.m
mailto: prabumps@yahoo.co.in
|
|
|
|
|
Your second form shouldn't know nor access the first form.
When opening the second form you just pass the id to that form.
There are several way's to do this.
1: Make a property on the second form and set this property from the first.
2: Make a constructor on the second form which accepts the id (and use that constructor on the first form)
3: (not to be used unless the id has to be used on several forms) Make a new class with a public shared variable in it and fill that one on the first form. Then access it on the second form
On a side note don't say that it's urgent, all questions are.
|
|
|
|
|
thanks...
but i want sample code for those, bcaz i now only i am learing, so plz send me the code.
|
|
|
|
|
Form2
public partial class Form2 : Form
{
private int iid;
public Form2(int id)
{
InitializeComponent();
iid = id;
}
}
Form1: (opening from form2 is in a button here)
private void btnOpenForm2_Click(object sender, EventArgs e)
{
Form2 frm = new Form2(1);
frm.Show;
}
Now you can use the id anywhere you want on form2
|
|
|
|
|
Hello
I have a requirement to print the images.For small images with the resolution (1024 X 768), print works fine. if the resolution is more. I need to either compress the image or print in multiple pages.
Can you please help me how to compress an image?
Best Regards
Shankar
|
|
|
|
|
Create a rectangle of the appropriate size and draw the image in the rectangle.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hi all,
In my application i am using a timer which gets the data for every one minute , but sometimes it is not happening ,its taking more than 15 minutes to call the timer_tick event.I am not understanding what the problem is.In my application i am using multi threading also which handles the another functionality , is this the problem
|
|
|
|
|
may be the data feched by ur application is huge so the processing time is much.
rahul
|
|
|
|
|
hi,
can i see code so i can figer out.
Thanks
Ali Zishan
London
|
|
|
|
|
|
-I have a picturebox 300*300 in size
-And a jpg 1200*1200 pixel 150 DPI
How to draw a quarter of image to picturebox with original size?
Thanks everybody
|
|
|
|
|
Not a quarter but a 1/16th.
How does the JPG exist? Is is a file, a Bitmap instance or what?
Regards,
Rob Philpott.
|
|
|
|
|
First thanks for answer.I load jpg to image object and draw a part of image(size=250*250) in picturebox.
Problem is image was draw in picturebox is smaller than i expect.(because i open jpg by ms paint and i saw 250*250 in ms paint is bigger 250*250 i draw in picturebox).
Hope you can explain.
Thanks.
|
|
|
|
|
Hmm. Not sure, although it sounds like a logical unit vs. device unit problem, possibly taking into account the DPI of your graphics set up.
My graphics card/monitor displays things at 98 dpi, so the scaling might be from the native 150dpi to the 98 (if you are the same), although I would expect things to be bigger than smaller in that case.
The DrawImage method of the Graphics class allows you to scale things, or the ScaleTransform method allows you to change the 'resolution'.
Regards,
Rob Philpott.
|
|
|
|
|
Thank for advise.I will research this problem.
|
|
|
|
|
Hi All,
I have developed an application in c# 2.0
I am going to launch my desktop application in market and I have 2 concerns regarding security of my application
1. Application licensing
2. database security
I don’t want anyone to use multiple installations of my application while he has paid me for 1 license and have a setup, how to prevent it?
I don’t want to show off my sql server schema while I have to deploy a database on client system with user id and password, how to attach an .mdf file with the sql server or anything else so that no one can check my sql database?
Hope you reply soon
Regards
Kaleem Ullah
|
|
|
|
|
LogiSmith wrote: I don’t want anyone to use multiple installations of my application while he has paid me for 1 license and have a setup, how to prevent it?
It is very tough to get a 100% perfect licensing system. I have used APIs from this[^] for my application. They are good and provide a decent way for managing the licenses and activations.
LogiSmith wrote: I don’t want to show off my sql server schema while I have to deploy a database on client system with user id and password
If you want to deploy the DB in user's system, it is very tough to secure it as user will have complete access to it and can hack in easily. Why don't you create a webservice which interacts with database located on your server and your applications interact with this webservice. So users will not have access to databases.
|
|
|
|
|
hi all,
when m modifying appconfig key it just doesnt save it
//my code
<appsettings>
<add key="T" value="True">
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings["T"] != null)
{
config.AppSettings.Settings["T"].Value = "False";
//config.AppSettings.Settings.Remove("DatabaseServer");
}
else
{
config.AppSettings.Settings.Add("Key1", "False");
}
config.Save(ConfigurationSaveMode.Full);
ConfigurationManager.RefreshSection("appSettings");
why is that happening !!!
|
|
|
|
|
Because you can't modify data in the app.config programatically. If you want user-specific data to be saved, you have to use the Settings object.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Your code works for me.
If you're looking for changes in your App.config, you're not going to find them there.
The changes are in the actual runtime configuration file named yourappname.exe.Config,
which will be in the same folder as the exe.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi everyone,now I have a winform Form1,in Form1,there is a TextBox1,and its Text is "abcd".
In the other project,I want to get the Text of TextBox1,as below:
Assembly assembly = Assembly.LoadFrom(@"ClassLibrary1.dll");
Type[] types = assembly.GetTypes();
FieldInfo[] fis;
System.Windows.Forms.TextBox tb;
for (int i = 0; i < types.Length; i++)
{
fis = types[i].GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
for (int j = 0; j < fis.Length; j++)
{
if (fis[j].FieldType == typeof(System.Windows.Forms.TextBox))
{
tb = fis[j].GetValue(Activator.CreateInstance(types[i]))as System.Windows.Forms.TextBox;
Console.WriteLine(tb.Text);
}
}
}
Console.Read();
But I have to create a instance "Activator.CreateInstance(types[i]))".Are there any ways that I can get the Text without create a Form1 instance?
Anyone who can help it would be appreciated.
|
|
|
|
|
Morven Huang wrote: Are there any ways that I can get the Text without create a Form1 instance?
Since the textbox is a member of Form1, you need to instantiate Form1 for getting access to text box.
|
|
|
|
|
That would be like asking for the colour of a car that doesn't exist. You know that cars have colours - but you the colour doesn't exist without the car.
|
|
|
|
|
|
Hai
Me with C#.net I want to make a text box to accept only numbers and decimal points(decimal point only once), so I tried to make a user control and is working fine except one problem. If if select all the data in the text box and try to enter a new value decimal point will not accept until I press the backspace. My user control code is a follows
string i;
int f;
public string Text
{
get
{
return NMTextBox.Text;
}
set
{
NMTextBox.Text = value;
}
}
private void NMTextBox_KeyPress(object sender, KeyPressEventArgs e)
{
try
{
string numaric = NMTextBox.Text;
for (int j = 0; j < numaric.Length; j++)
{
char myChar = numaric[j];
}
if (NMTextBox.Text == "")
{
f = 0;
}
if (e.KeyChar.ToString() == ".")
{
++f;
if (f >= 2)
{
e.Handled = true;
}
}
if (i == "8")
{
f = 0;
for (int j = 0; j < numaric.Length - 1; j++)
{
if (numaric[j].ToString() == ".")
{
++f;
}
}
}
if (e.KeyChar.ToString() != "." && Char.IsNumber(e.KeyChar) != true)
{
if (i != "8")
{
e.Handled = true;
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.StackTrace, ex.Message.ToString());
}
}
private void NMTextBox_KeyDown(object sender, KeyEventArgs e)
{
i = e.KeyValue.ToString();
}
Thanks & Regards
|
|
|
|