|
thank you very much i saw that but may couldnt get that any way thanks once again.
|
|
|
|
|
Hi there, how can I call any one of the winAPI functions,
in a C# code,
and does it make a difference if the code is a service not an application
Thanks in advance
There is always something to learn
|
|
|
|
|
|
|
Thanks all
There is always something to learn
|
|
|
|
|
You are welcome
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
Likewise
|
|
|
|
|
Can anyone please tell me in C# how to find a particular file is loaded by which processes? For example I want to check if "C:\test.doc" is loaded by which processes.
Thanks,
Mushq
|
|
|
|
|
|
Why? What do you want to do with it?
|
|
|
|
|
Thanks for reply.
PIEBALDconsult wrote: What do you want to do with it?
Actually some of my requirement wants to kill those processes.
Regards,
Mushq
|
|
|
|
|
Please anybody give me the LAN TicTacToe game in C# Win32
|
|
|
|
|
|
Hi Guys. I need some Advice/Help please.
I have two portions to my application that I am working on at the moment and they both working fine but I want to combine the two or to have the one matching data from the other one.
First, I have this Button event that would take data from a txtbox that would match data and return a MessageBox with a String. See below.
private void btnValidate_Click(object sender, EventArgs e)
{
int pcode = 0;
if (int.TryParse(txtboxPcode.Text, out pcode) == false)
{
MessageBox.Show("Invalid Integer!");
return;
}
if((pcode >= 4731) && (pcode <=6499))
{
MessageBox.Show("Eastern Cape");
return;
}
if ((pcode >= 9300) && (pcode <= 9999))
{
MessageBox.Show("Free State");
return;
}
}
The other section in my app I am using FileHelpers to import a CSV file into a MultiLine txtbox. This works fine. I want to use one of the files in the filehelpers import to match to the above code and return the matched value in the MessageBox. Below the FileHelpers Code. In the below code I want to use the imp.CallComments and match that to the pcode above and return the value currently returned in the Messagebox.
private void btnOpenFile_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() != DialogResult.OK)
{
this.Close();
}
else
{
txtboxSelectFile.Text = openFileDialog1.FileName;
}
string filePath;
filePath = txtboxSelectFile.Text;
FileHelperEngine<CsvImp> engine = new FileHelperEngine<CsvImp>();
engine.ErrorManager.ErrorMode = ErrorMode.SaveAndContinue;
CsvImp[] res = engine.ReadFile(filePath);
if (engine.ErrorManager.ErrorCount > 0)
engine.ErrorManager.SaveErrors("Errors.txt");
foreach (CsvImp imp in res)
{
txtboxDisplay.Text += imp.CompanyCode + "\t" + imp.Caller + "\t" +
imp.Reference + "\t" + imp.Agent + "\t" + imp.CallComments + Environment.NewLine;
}
}
Can somebody please advise me what the best way of doing this would be please? Any advice is greatly appreciated.
Thanking you in advance.
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
I'd refactor the transformation code out of the button click handler into a separate routine that returns an appropriate string for the given input like:
private string TransformMyString(string inputStr)
{
string retval = "";
int pcode = 0;
if (!int.TryParse(inputStr, out pcode))
{
retval = "Invalid Integer!";
}
else if ((pcode >= 4731) && (pcode <= 6499))
{
retval = "whatever";
}
return retval;
}
Then you can MessageBox.Show the return from the function of put it in a text box or do whatever else you need to do.
|
|
|
|
|
Well my problem is the next buddies
I have a GridView, well Actually a RagGrid From telerik control
I get the data executing a StoreProcedure and storing in a Datatable
the I just use the next code
<br />
DataTable dtListValues = null;
dtListValues = LoValues.oListValues(Values.PKValue);
this.rgValues.DataSource = dtListValues;
this.rgValues.DataBind();
and then the page ends with this
NameColumns PKValue NameValue isActive
but!! I don't want to use this names!!
And to "fix" this I try to use this
<br />
dtListValues.Columns[0].Caption = "Code";<br />
dtListValues.Columns[1].Caption = "Name";<br />
dtListValues.Columns[2].Caption = "Active";<br />
I already used this code after and before executing the DataBind
But!!!! It doesn't work!!! =(
Could someone Tell Me where I'm wrong ?
I hope you can help me please
thanks in advanced
Greetings!!!
|
|
|
|
|
I'm not familiar with that datagridview but I would look to it's properties for setting the caption (column header) instead.
|
|
|
|
|
Hello!!
Yes, I try this too, and I concluded that the correct code (according to my nerves [¬_¬])
was this :
<br />
dtListValues.Columns[0].Caption = "Code";<br />
dtListValues.Columns[1].Caption = "Name";<br />
dtListValues.Columns[2].Caption = "Active";<br />
because when I was looking the properties in debugging time I saw the names of the captions in this properties
but when I try to change it, It doesn't work
In any way, too much thanks for your Help!!
|
|
|
|
|
Okay, so me and my buddy were having this discussion today.
Assume a case in C# where we have two classes, class A and class B, with A having an array of objects of B.
Now when we want to use these classes from a different class C (without inheritance that is), we create two instances of A and B. However all members of class A and a few from B are to be initialized before they can be used in C.
So the argument was abouthow to have this initializing logic in the constructor for class A. But then that would mean having a part of the logic also in the constructor for class B.
Instead why not having a public method in class A which takes care of this logic?
The argument stopped at how much of memory duz it take to invoke and execute two constructors instead of one public method?
Any takers?
------------------------------------
Vision is the ability to see the invisible
|
|
|
|
|
The constructor for B should construct a B.
The constructor for A should construct an A, which may involve instantiating the array of B, and may involve instantiating a number of Bs to put into that array.
The constructor for C should construct a C, whatever that entails.
Or... each class should have an Initialize method that does what the constructor would do otherwise.
Perhaps you didn't ask the question well.
|
|
|
|
|
Or you could use the Factory Pattern
Scott P
"Run for your life from any man who tells you that money is evil. That sentence is the leper's bell of an approaching looter." --Ayn Rand
|
|
|
|
|
Yes, but there still need to be constructors and maybe initializers.
|
|
|
|
|
Well the question is, is it better to have two different constructors (A & B) to execute when we can one public method (in A) to do this job for A & B constructors?
The main purpose is to save the CLR overhead of executing two different constructors than one public method.
Duz it make sense now?
------------------------------------
Vision is the ability to see the invisible
|
|
|
|
|
Have you timed it yourself? You could also put together a test app and run it through ildasm to look at the IL. Regardless, the constructors get called if they're in a public method or not. The constructor in B (there's one that the compiler generates even if you don't type it in yourself - use ildasm and see), it gets called. Period. Any instance of any object needs a sync block index and a type pointer, plus all the space for it's members on the heap. Doesn't matter if you make your object family in a Factory Method or not, they get called. With the Method call there's additional overhead for putting the instruction on the stack and making the call, plus the return.
Scott P
"Run for your life from any man who tells you that money is evil. That sentence is the leper's bell of an approaching looter." --Ayn Rand
|
|
|
|
|
Thanks a lot Scott,
carbon_golem wrote: Have you timed it yourself?
Nope I havent timed it yet, how do i do that?
I did look at the ildasm. Thanks a lot, it cleared a big stumble in the thought process.
Okay agreed that with a method call, there is an additional overhead for puting the instruction on the stack and the return.
However compare it to the scenario where the class A and class B objects are being created more than once in Class C, would it be more economical to invoke the constructors everytime and initialize the members, even if we dont need them to be initialized; or just call a method once and pass the object references to initialize them once?
The IL clearly showed how a simple initialization like string.Empty is costly to refer to the Empty member of the system.string. Why do it twice? why not do it just once in a method call and avoid the redundancy?
Agreed there is a cost to make the call to the constructor and the method, but what about the cost of redundancy by calling the class ctor but not using that object any further.
Pass the object to a method that initializes/constructs it when it is needed.
What say?
------------------------------------
Vision is the ability to see the invisible
|
|
|
|