|
As a best practice it is advised to refractor functions that do similar things in different classes. That way you avoid having problem with too much code in the same .cs file. In my case I choose to have at most 400 lines of code in a class.
I am fighting against the Universe...
Reference-Rick Cook
|
|
|
|
|
I program for web application and just wanted to explore other side of the programming on win forms.
I am building a account/calculation program for practice. There I got to things which I would like to know.
1) I am using Lable Control to print the values of the ArrayList. What is the best place to print?
2) How I can provide the printing capability to the end program. Or on which control the print commond
to work.
3) In Web programming I could use the Validation control. What could be similar control in win form.
4) How to provide the "Save" capability to certain data. ???
This is my first post here on the code project if these are too many questions plz let me know.
Thanks
Learning aammi@yahoo.com
|
|
|
|
|
I wrote some Form and i show this Form by calling the method ShowDialog - with no parameter.
My problem is when i show this Form - i could not set Focus to him.
What to do ?
Thanks for the help.
|
|
|
|
|
Yanshof wrote: I wrote some Form and i show this Form by calling the method ShowDialog
You created a new form in a console application? Be more specific about your problem. If you created a windows application project with a form, displaying another form by calling the ShowDialog is enough to make it display because is it modal and the focus is by default set to the second form. If you have a console application displaying a modal form won't be enough to make it run until you close it, you have to call Application.Run(myform)
Do your best to be the best
|
|
|
|
|
Ok,
What i do is create the Form in some other C# file - and the other C# file is call by using Com from some C++ application.
|
|
|
|
|
I'm trying to create a schema.ini file to impport data from a csv file and have hit a snag.
According to this article - http://msdn2.microsoft.com/en-us/library/ms709353.aspx - the first line in the schema needs to be the file name.
My problem is that I get uniquely named files and have no idea what they will be untill I get them.
Is there a way to omit the first line in the schema or just specify the filename as *.csv ?
Thanks,
Nathan
|
|
|
|
|
digsy_ wrote: Is there a way to omit the first line in the schema or just specify the filename as *.csv ?
I've never used the Text driver, so....
As far as I can tell, no you can't remove this. You are probably going to have to write this file out with the name of the file you're importing for each and every file you import using this method.
The alternative is to write your own import implentation from scratch or try to find a third party CSV parser class. Search the articles here for "CSV" and you should find at least one.
|
|
|
|
|
hi it may b a newbi question but i hvnt got d answer
here is somethings i did
in form1 class
1 I have a statusbar in form1 class and statuslabel1 ,
2 i have made it public control .
3 I have created a public property StatusPanelText which sets the text of statuslabel1.Text= value
Now in IOFunctions class (this is another class where i hv IO related functions)
i have a function which searches the files in given DIR (dirinfo,fileinfo etc) and i want to display file names in the statuslabel1.text
in class i create a instalce of form1
form1 objForm1= new form1();
objForm1.StatusPanelText =filepath;
now this text shows in new form up if i say objform1.show();
but i want the existing form statusbar to change .....
any help ????
-- modified at 9:29 Tuesday 2nd October, 2007
Hej again ...
there is some stuff i need to mention i guess (after d responses)
1) my problem (according to me ) is as i create a new instance of form1 the changes happen in d object form1..so i want to get hold of existing Form1 object and controls...
2) I want this (update statusbartext) in other classess as well (DBrelatedclass,regutl etc) most of the classes are static as they contain only methods/functions.
after some search i think (?) singleton pattern is near to solution but i am not able to impliment it
hope new explanation adds value....
-- modified at 4:25 Thursday 11th October, 2007
|
|
|
|
|
pramarathe wrote: Now in IOFunctions class (this is another class where i hv IO related functions)
i have a function which searches the files in given DIR (dirinfo,fileinfo etc) and i want to display file names in the statuslabel1.text
in class i create a instalce of form1
form1 objForm1= new form1();
objForm1.StatusPanelText =filepath;
now this text shows in new form up if i say objform1.show();
but i want the existing form statusbar to change .....
Create a function in your form's class, call it UpdateStatusLabel(string filepath) or something.
When searching for the file in IOFunctions, send the filepath as an argument your Update function in your form's class. when the form calls the function it can update that control.
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
Well, you could store a reference to form1 in your IOFunctions class. Suppose that you have an implementation like this:
public class IOFunctions
{
private Form1 _form;
public IOFunctions(Form1 parent)
{
_form = parent;
}
public void DoSomething()
{
_form.StatusPanelText = "Hello";
}
} Alternatively, you could create an event in your IOFunctions class which you would respond to in the form class to display the message. This is all covered in Colin's excellent article[^] here. Well worth reading.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Another way of getting acces to the already opened form is to send to the second class, in the constructor (for example) the handle for the form that is opened. I'll give you just a small example:
<br />
public partial class Form1 : System.Windows.Forms.Form<br />
{<br />
...<br />
...<br />
IOFunctions io = new IOFunctions(this.Handle);<br />
...<br />
<br />
}<br />
<br />
public class IOFunctions<br />
{<br />
private Form mainForm = null;<br />
<br />
public IOFunctions(IntPtr handle)<br />
{<br />
mainForm = (Form)Control.FromHandle(handle);<br />
}<br />
<br />
}<br />
Do your best to be the best
|
|
|
|
|
guess solved the problem ... d singleton thing ...
let me know my approch is right or wrong ...
things i did ..
0.1 ) private static form1 oForm = null; //global variable 0.1 is coz i m lazy enf to change 1 to 2 n etc etc :P
1 ) created a instance method
public static form1 instance()
{
if (oForm1 == null)
{ oForm1=new form1();
}
return oForm1;
}
2 ) in form1 consturctor assigned oForm1 = this; // so i have the instance of current form
3 ) a exposed property which gets sets statusbarpaneltext
4) in my staic class created private variable f
FORM f= form1.instance() // its FORM and form1 resp .. no typo here ..
5) where ever i want to update statusbar now i write
f.statusbarpaneltext= dirInfo.fullpath.tostring(); //for eg ..
thats abt it ... if m missing some systax i can update it ... its working for me .. now only(?) thing is impliment a thread to see this
now m wating for comments on how m wrong n where ...plz ....
i talk to myself.....
|
|
|
|
|
Hy
I want to know how can I send a space with SendKey.Send?
thx
|
|
|
|
|
SendKeys.Send(Keys.Space);
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
Doesn't work. The SendKey.Send receive a string parameter not a Keys
|
|
|
|
|
In that case, how about SendKeys.Send(" "); ?
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
My bad. Tack a ToString() to the end of that
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
Doesn't work.
If I put SendKey.Send(" ") it put me more than one space and the application freeze for few moments.
If I put SendKey.Send(Keys.Space.ToString()) it put me many SpaceSpaceSapce and the program will not stop
|
|
|
|
|
try SendKeys.Send("{SPACE}");
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
mihksoft wrote: If I put SendKey.Send(Keys.Space.ToString()) it put me many SpaceSpaceSapce and the program will not stop
It's pretty clear you doing it 3 times then! So use SendKey.Send(" ") and make sure it happens only once (which it is not doing).
|
|
|
|
|
I have created a COM server in which a collection of vectors need to be exposed to C# sharp client .
Each vector contains a array of structures and this vector need to be embedded inside a container, say another vector or list.
Code:
typedef struct
{
std::string name;
std::string type;
} STAGE_INFO;
std::vector<stage_info> m_stages;
m_stages.push_back(current_stage)
Since STL classes are not accessible in C#, I used a SAFEARRAY and VARIANT for exposing them. But I am not successful because of the following reason .
1) I am not able to create a VARIANT array of structures.
2) I created a SAFEARRAY of structures and included it in a VARIANT, but when accessed in C# as Object, I am not able to get the structure. Though I am able to typecast it into a Object array , but if accessed in separte gives exception.
3) I am able to access the members of the structure as they are string but not a STRUCTURE as a whole.
4) I tried containing a VARIANT of SAFEARRAY'S in another VARIANT, but it gives a casting error.
5) CComVariant cannot have USD's and VARIANT if used has some problem of Memory Leaks.
Please let me know if you have expertise in COM and C#.Net Interoperability.
or
Even if you have some alternate solution for this problem?
Thanks In Advance .. expecting your earliest reply.
_________________
Life Rocks,
$dhanu's$
|
|
|
|
|
This is going to be very difficult because C# has no knowledge of std::vector, your STAGE_INFO struct, and to worsen things, your struct has std:string objects in it, which C# also has no knowledge of.
Instead of trying to make C# see all this stuff, could you instead expose functions that get data from the vector and return it in a C# friendly way? This could be done either using standard exported C functions or by using a C++/CLI wrapper which is then available to the managed world.
|
|
|
|
|
Hello,
Recently I came up with seeing a class some thing like this
public class Stack<T> : IEnumerable<T>, ICollection, IEnumerable
{
}
Could any one tell me what is <T> means ? Why it has to be given like this ? Any ideas ?
-- modified at 6:50 Tuesday 2nd October, 2007
HTML tag next to class was not visible
|
|
|
|
|
The reason I despair for the future of this industry, is the large number of people who are scared of google.
The Stack class impliments three interfaces. It does this so that differing objects can share a common interface, when used for the same purpose.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I think what Navaneeth tried to ask is, why is the Stack class implementing the IEnumerable Interface twice?!? Honestly I dont know either...
|
|
|
|