|
Well i believe u must be familiar with properties and functions. Every object of any class has some properties and methods. e.g
class MyClass
{
int i;
string j;
void MyClass(){}//this is constructor
Public void MyMethod( int x )//this is member function
{
return x*x;
}
}
Now if i make an object of this class
MyClass obj = new MyClass();//Notice I called the constructor.
Because obj is an instance of MyClass so it must have a cope of i,j and MyMethod(int x) of its own.
So what i should do to access these properties(i,j) or member function of MyClass.............Here is wat i would do.
obj.i=9;//so i m using dot to access the properties of the object.
obj.MyFunction(8);//Here i m calling the member functon.
Now to the code u provided.
obj.delegateobject = new windowsdelegates.Form2.nameofdelegate(SetText);
Look at this in pieces
obj is an object of any class
this class must have some property delegateobject
we are assigning this property(delegateobject) an object of class form2 by setting its name "Set Text". So here is the moral lesson dot is also used to access classes within a namespace.
I will recomend u so hav some good book on C#.NET for beginner level. u will get the answers to most of ur questions.
|
|
|
|
|
well, i just run thru the question, here you declared int i, and string j.. both are private members in class MyClass.
you can keep the cariables as public if you want to access it. If you want to access the private members dotnet provides another techique... "property".. in which you have more control....
like private int i;
public int I
{
set
//
get
//
}
My small attempt...
|
|
|
|
|
sorry sir,is there any relationship between i&I?
just like this:
class Distance
{
float start,finish;
public float Start//can i write it as start?
{
get{return start;}
set{if(start>=0)start=value}
}
...
}
public class MainClass
{
public static void Main()
{
Distance d=new Distance();
d.Start=5
Console.WriteLine(d.start)
}
}
Is there a really value of Start which equals start?which word gives the Start a value?i'm sorry,my english is so bad ,I don't know whether you got my mind or not.
另:祝天天快乐。
|
|
|
|
|
heii dont worry what you wrote was correct....
the thing is simple that, private members cant access from out side the class.. thats why you got error earlier........
now to access that private members, we can use "Property", that is what you exactly did...
usually we declare the member with small letter and Property with Capitol letter
as float start;
and public float Start
{
}
My small attempt...
|
|
|
|
|
yeah,I got lots of things from you,thanks again.
|
|
|
|
|
okie okie..... Just try to get some books of C# and start.. otherwise you will get these kind of questions soon
My small attempt...
|
|
|
|
|
Thankyou Azif
|
|
|
|
|
gud pm sir, im working with my project using c#, theres a slight problem when i view my data with crystal report,im using with date range(date from and date to)and it was supposed to be generating report with the date that i pick,apparently it appears that all my data in my database was view in my crystal report... it just show all my data.... pls help, im working with this with almost a month thank you...
bhebhekoh
laguna,philippines
|
|
|
|
|
Please be specific about your question and make it more clear (don't use textspeak or continual run-on sentences)...
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
hi my task is to change the font,font size, color and style of a label this can be done easily by a font dialog box but here i am using comboboxes and textboxes to set the properties to a label dynamically
as the properties like font,font size are read only type i am getting problem
if anyone know's how to do it please let me know
regards
sindhu tiwari
always wishing to learn
|
|
|
|
|
You have to replace the entire font every time you change a property. The Font property on a label is not read only, is it ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
thank u sir now everything is set except the font style
i am unable to set the font style
the code is
lab[foc].Font = new Font(global.font, global.fontsize, FontStyle.Regular, GraphicsUnit.Point);
i am using a label array and global is a class font fontsize are static variables if u have any idea plz tell me how to set the fontstyle ...
i want to use a string at fontstyle
learn before u earn
|
|
|
|
|
Enum.Parse will allow you to turn a string into an instance of the FontStyle enum.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi,
I wannt to know how can I get previous focused control. My problem is when I click on panel then focus in textbox is lost. I have 5 textboxes and wannt set focus back to proper textbox.
I also tried OnLeave of textbox to discover which control will get focus, but I have problem too.
Any suggestion?
Thank in advance,
Jure
|
|
|
|
|
panel is only a container not any control to interact with.
Every ctrl has its index property.So make panel index prty after textbox property.
Store previous control Id to some global variable in textbox lost focus event.After you had complete ur work on clicking on panel,just use this Id and use focus() to assign focus on that control.
Regards
Chintan
www.visharadsoft.com
(I am thinking to change humans to computer, but unfortunately GOD will not give me the source code)
|
|
|
|
|
Hi friends,
I'm creating an application which deals in excel sheets...here i have a GUI from which the user can select an excel sheet...the selected excel sheet should open in the GUI itself.
Ican get that from Datagridview but the catch here is that i want to display the excel sheet exactly as it is...i mean it should should show the FORMULAE and also the formatting of the cells just as in the excel sheet...in short wht im doing is creating a Ui in which user can view and manipulate the values in the excel just as he does in the excel sheet normally...
Can any one tell me how to about this...
|
|
|
|
|
dudedotnet wrote: Can any one tell me how to about this...
Yup - you're wasting your time. If you want to edit Excel spreadsheets in a GUI just like Excel then use Excel.
Me: Can you see the "up" arrow?
User:Errr...ummm....no.
Me: Can you see an arrow that points upwards?
User: Oh yes, I see it now!
-Excerpt from a support call taken by me, 08/31/2007
|
|
|
|
|
hi i am generating a word document using c# i required the document to be formated in two colums but i dont know how to do that can anyone help me.
|
|
|
|
|
You can do this only if you have libray(dll) file for MS word class.I think you can get it from microsoft site.
Regards
Chintan
www.visharadsoft.com
(I am thinking to change humans to computer, but unfortunately GOD will not give me the source code)
|
|
|
|
|
It can be done through the Office Interop library.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi all.
We have a C# 2.0 prog writing to a csv file for emailing bills to customers.
So, we have the contents of the csv file in a string.
We use a stream writer to send it to the file.
We open the file in Excel (2003) and the £ symbol is now prepended with Ậ
Seems the encoding has turned the £ into UTF-8 and stuffed and extra charachter in there, that Excel renders incorrectly.
We tried everything, Encoding in various ways, using File.WriteText, converting to bytes using Encoding, nothing worked as expected.
In the end we settled on this:
<br />
byte[] bArr = new byte[str.Length];<br />
for (int idx = 0; idx < str.Length; idx++)<br />
{<br />
char c = str[idx];<br />
byte b = (byte)c;<br />
bArr[idx] = b;<br />
}<br />
File.WriteAllBytes(csvFileName, bArr);<br />
Pretty nasty, really.
So, question: What is the correct encoding level/object/type to use to do this more elegantly?
Thanks in advance.
|
|
|
|
|
A would guess that Excel is reading the file as an ANSI file, that is/was the standard text format in windows prior to unicode.
Try the Encoding.Default encoding, that will give you the encoding currently used by the system for ANSI files.
---
"Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things."
-- Douglas Adams
|
|
|
|
|
I need to ping IP with linux commands "ping xxx.xxx.xxx.xxx" . and run it with Mono on Linux server.
Let's see my code...
Process P = new Process();
P.StartInfo.CreateNoWindow = true;
P.StartInfo.FileName = "ping";
P.StartInfo.RedirectStandardOutput = true;
P.StartInfo.Arguments = " 202.57.191.167";
P.Start();
P.WaitForExit();
string output = P.StandardOutput.ReadLine();
while (output != null && output!="")
{
Console.WriteLine(output);
output = P.StandardOutput.ReadLine();
Thread.Sleep(500);
}
Console.ReadLine();
Then upload and run it,it throw exception...
<br />
"Unhandled Exception: System.InvalidOperationException: UseShellExecute must be false when redirecting I/O.<br />
at System.Diagnostics.Process.Start_shell (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x00000]<br />
at System.Diagnostics.Process.Start_common (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x00000]<br />
at System.Diagnostics.Process.Start () [0x00000]<br />
at (wrapper remoting-invoke-with-check) System.Diagnostics.Process:Start ()<br />
at ProcessLinuxCommands.Program.Main (System.String[] args) [0x00000]"<br />
Could u help me what is this bug?
Does Mono implement the Process class?
thank =)
|
|
|
|
|
How about trying to set the StartInfo.UseShellExecute property to false as the exception message indicates.?
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hi
I am working on a desktop application using C# and .NET 2.0.
In my DataSet I have two tables say table1 and table2. They have one to many relation (no rule is set like for update, delete or accepct/reject changes). When I drop a binding source for the parent table i.e table1 on the windows forms, I get another binding source for child i.e table2BindingSource1 after rebuilding the project. That is really helpful because when I set
//this.BindingNavigator1.BindingSource = table1BindingSource;
The self created BindingSource collaborates with the navigator itself and I need not to do any extra coding.
Now the problem is when I do
//this.BindingNavigator1.BindingSource.CancelEdit();
to cancel any changes made to DataSet in case user clicks Delete button one the Navigator.
This only works for the parent table i.e table1 and not for the child table or say for self created BindingSource.
How can I apply this CancelEdit for both the tables in the DataSet ( for both BindingSources ).
Can anybody help me out?
|
|
|
|