|
using Microsoft.Win32;
string strAssemblyPath;
strAssemblyPath = System.IO.Path.GetDirectoryName(base.Context.Parameters[ASSEMBLYPATH_STATENAME]);
Process.Start(strAssemblyPath+"\\Application.exe");
RegistryKey MainKey;
MainKey=Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths");
RegistryKey ApplicationKey=MainKey.OpenSubKey("Application",true);
ApplicationKey.SetValue("Application.exe",strAssemblyPath+"\\Application.exe");
Check the Above code written in c#. This Code i have written for writting my application path into registry.
And u can add the application to the Start up in another way also.
Check while creating setup u can create a chort cut to the start menu startup folder. that will also run the application.
Arun Kumar Sabat
|
|
|
|
|
Thanks for your replay.
i have another doubt?
how can i hold system shut down process
until user close my c# application properly...
|
|
|
|
|
Hi,
I have two datagrids on a WinForm. I want to keep them synchronized so that when the user scrolls one of them, I can programmatically scroll the other one an equal amount. The datagrid is new to me. How can I do that?
Royce
|
|
|
|
|
If you had searched for answers to your problem first, you may have run across http://www.codeproject.com/script/comments/forums.asp?msg=911474&forumid=1649#xx911474xx[^], which describes the solution to what you're searching for. The fact that this is for a RichTextBox doesn't matter; the same solution works for practically all scrollable controls so long as the controls that they encapsulate handle the standard scrolling messages.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hi,
I'm using C#Express Beta and accordingly the framework 2.0.
I recently realized that my application, when starting has a workingset peak of ~128 MB. I startet wondering a bit because the application didn't yet do anything really usefull.
So I fired up the IDE, created an empty WinForms project and compiled a release build. Please note that I have not added any extra code! Here is what I have figured out:
1. On launching the resulting exe, the TaskManager shows a workingset of ~70 MB.
2. When I minimize the MainForm window the workingset shrinks to ~400 KB.
3. Maximizing the window again results in a workingset of ~1460 KB, which I could live with.
Does anyone have an idea how to go on about this?
BTW.: Is there a way to monitor in detail what and where and how your application is using up the memory? I have a monitor to get information as of what modules are loaded, but is ther a way to figure out of what classes or resources are taking up the space?
Any pointers are highly appreceated.
Thanks in advance,
Matthias
If eell I ,nust draw to your atenttion to het fakt that I can splel perfrectly well - i;ts my typeying that sukcs.
(Lounge/David Wulff)
|
|
|
|
|
|
Thanks for your reply. I've downloaded the tool and am now trying to figure out if and how it could help me
Thanks again!
Matthias
If eell I ,nust draw to your atenttion to het fakt that I can splel perfrectly well - i;ts my typeying that sukcs.
(Lounge/David Wulff)
|
|
|
|
|
Hi,
How can I use this command in C# ?
Inet.Execute "http://200.100.100.100/econtrol.html", "POST", "P1=t"
Best Regrads
youssef
|
|
|
|
|
What's Inet?
/\ |_ E X E GG
|
|
|
|
|
Inet is a component in VB6 for communicate in HTTP, FTP, HTTPS.
I receive this command in a VB6 project and me I working in c++ or c#
Can you help me for translate this command in C# or C++ ?
Best Regards
youssef
|
|
|
|
|
Using the HttpWebRequest and HttpWebResponse classes.
|
|
|
|
|
|
If you don't want to go the programatic way and if this inet thingie is an exe which accepts command line params:
System.Diagnostics.Process.Start(@"C:\Path\inet.exe", @"http://200.100.100.100/econtrol.html POST P1=t");
|
|
|
|
|
Why this code doesn't working ?
Is it correct ?
using system.net;
System.Net.WebRequest req = null;
System.Net.WebResponse rsp = null;
try
{
req = System.Net.WebRequest.Create("http://200.100.100.100/econtrol.html?P8=t");
req.Method = "POST";
req.Timeout = 5000;
}
catch (Exception ex2)
{
string sErr = "Cannot connect to Internet. " + ex2.Message;
}
youssef
|
|
|
|
|
Hi,
I have the below code which runs after choosing an item from the listbox (choose the first one). Goes to the below item after 5 seconds and then goes to another after 5 sec again... So here is my question: I have a func which I named as process() I want to run this func only once when each item is selected in the listbox? So how can I do that???
Thank you,
Cem Louis
<br />
<br />
using System;<br />
using System.Drawing;<br />
using System.Collections;<br />
using System.ComponentModel;<br />
using System.Windows.Forms;<br />
using System.Data;<br />
using System.Timers;<br />
using System.Threading;<br />
<br />
namespace WindowsApplication14<br />
{<br />
public class Form1 : System.Windows.Forms.Form<br />
{<br />
private System.Windows.Forms.ListBox listBox1;<br />
private System.Windows.Forms.Button button1;<br />
private System.Timers.Timer timerClock = new System.Timers.Timer();<br />
private System.ComponentModel.Container components = null;<br />
<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
InitializeTimer();<br />
<br />
}<br />
<br />
public void InitializeTimer()<br />
{<br />
this.timerClock.Elapsed += new ElapsedEventHandler(OnTimer);<br />
this.timerClock.Interval = 5000;<br />
}<br />
<br />
protected override void Dispose( bool disposing )<br />
{<br />
if( disposing )<br />
{<br />
if (components != null) <br />
{<br />
components.Dispose();<br />
}<br />
}<br />
base.Dispose( disposing );<br />
}<br />
<br />
#region Windows Form Designer generated code<br />
private void InitializeComponent()<br />
{<br />
this.listBox1 = new System.Windows.Forms.ListBox();<br />
this.button1 = new System.Windows.Forms.Button();<br />
this.SuspendLayout();<br />
this.listBox1.Location = new System.Drawing.Point(8, 8);<br />
this.listBox1.Name = "listBox1";<br />
this.listBox1.Size = new System.Drawing.Size(120, 95);<br />
this.listBox1.TabIndex = 0;<br />
this.button1.Location = new System.Drawing.Point(8, 112);<br />
this.button1.Name = "button1";<br />
this.button1.Size = new System.Drawing.Size(120, 23);<br />
this.button1.TabIndex = 1;<br />
this.button1.Text = "Run";<br />
this.button1.Click += new System.EventHandler(this.button1_Click);<br />
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);<br />
this.ClientSize = new System.Drawing.Size(136, 142);<br />
this.Controls.Add(this.button1);<br />
this.Controls.Add(this.listBox1);<br />
this.Name = "Form1";<br />
this.Text = "Form1";<br />
this.Load += new System.EventHandler(this.Form1_Load);<br />
this.ResumeLayout(false);<br />
<br />
}<br />
#endregion<br />
<br />
[STAThread]<br />
static void Main() <br />
{<br />
Application.Run(new Form1());<br />
}<br />
<br />
private void Form1_Load(object sender, System.EventArgs e)<br />
{<br />
listBox1.Items.Add("Arthur");<br />
listBox1.Items.Add("Alex");<br />
listBox1.Items.Add("Amie");<br />
listBox1.Update();<br />
}<br />
<br />
private void OnTimer(object source, ElapsedEventArgs e)<br />
{<br />
this.nextvalue(this.listBox1.SelectedIndex);<br />
}<br />
<br />
private void button1_Click(object sender, System.EventArgs e)<br />
{<br />
if(this.listBox1.SelectedItem!=null)<br />
{<br />
this.timerClock.Start();<br />
}<br />
else<br />
{<br />
MessageBox.Show("Select an Item");<br />
}<br />
}<br />
<br />
private void nextvalue(int currentPosition)<br />
{<br />
if(currentPosition+1<=this.listBox1.Items.Count-1)<br />
{<br />
this.listBox1.SetSelected(currentPosition+1,true);<br />
}<br />
else<br />
{<br />
this.timerClock.Stop();<br />
}<br />
}<br />
<br />
private void process()<br />
{<br />
}<br />
}<br />
}<br />
|
|
|
|
|
Add a boolean class member that starts out as false. Whenever the timer event is triggered, check if it's false. If so, set it to true. In the ListBox SelectedIndexChanged event handler (or whatever the event is called that gets called whenever you select a different item from the listbox), set the boolean to false again, thus resetting it and allowing the timer event to run again.
This way, Process() can only run when a different item has been selected. And since the Process() then sets the boolean flag to true, it will only run once.
<br />
bool itemIsInTimer = false;<br />
<br />
private void listbox1_SelectedIndexChanged(object sender, System.EventArgs e)<br />
{<br />
this.itemIsInTimer = false;<br />
}<br />
<br />
private void process()<br />
{<br />
if(!this.itemIsInTimer)<br />
{<br />
this.itemIsInTimer = true;<br />
}<br />
}<br />
|
|
|
|
|
I have the following:
To read an image from the northwing db im doing the following (im using 78 as the current images in the northwind db have 78 bytes of header information):
<br />
ms.Write(img, 78, img.Length-78);<br />
<br />
bmp = null;<br />
bmp = new Bitmap(ms);<br />
Then to write the image to the db:
<br />
FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);<br />
<br />
BinaryReader br = new BinaryReader(fs);<br />
<br />
byte[] photo = br.ReadBytes((int)fs.Length);<br />
The problem is I need to add 78 bytes when writing a new image to the db, so that when I read the image its like the others that already exist in the db. Anybody know how to do this?
|
|
|
|
|
You will just have to create a new byte array with the 78 bytes in place, then copy the bytes from the read buffer to the other array.
|
|
|
|
|
I realize that I can override the PaintMethod of the DataGridTextBoxColumn class in order to change the color of cells within a DataGrid.
I'd like to change the colors of individual columns headers also. Does anyone know if that is possible?
How might I do that?
Thanks!
Mark Mokris
|
|
|
|
|
Will you check my article on DatagridFormattings. It may help you out.
Sreejith Nair
|
|
|
|
|
Hello
Basically iam vb programmer,i was declare global variable in module level.
where can i declare the global varibles in c# ,how can i access that
varible
|
|
|
|
|
C# does not support global variables per se, it isn't good a object oriented design to have lots of global variables floating around. However, you can create static variables on a class which are accessible globally. For example:
public class GlobalConfiguration
{
private static int _sqlServerTimeout = 60;
public static int SqlServerTimeout
{
get
{
return _sqlServerTimeout;
}
set
{
_sqlServerTimeout = value;
}
}
}
Of course, you don't NEED to wrap the variable in a property, but it is good practice to do so. You can add extra validation in the setter, and the getter can internally operate a lazy lookup if the variable is not often required, but getting the value takes time (Once you have generated the value the first time you can store it, so that the next time you need the value it can be returned quickly).
Do you want to know more?
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
|
|
|
|
|
First check out the tutorials at http://www.csharp-station.com/
I don't fully understand you question but it seems to me that you are trying to declare a public variable in a namespace ? Like that ?
namespace Something
{
public int myvariable = 0;
}
That's not possible. All members in C# must be inside objects (classes, structs). So what you must do is:
namespace Something
{
public class MyClass
{
public static int myvariable = 0;
}
}
The static modifier ensures you can access the variable without creating a new instance of the class.
P.S. You should however avoid using this tehnique as global variables are rarely needed and they're rally not usefull usually.
|
|
|
|
|
hi,
This question is regards to code optimization.I have near to 100-150 labels and same number of textboxes in a my main form.And this form also contain few other controls. Say panel, combo box etc.
The data fetching is also dynamic based on users requirement. I check the maximum time with possible chances for data request(range).Performance is good. So i am not worried about data fetching.
My problems is with this much controls and their dynamic sub instances.I found my application becoming too very slow when this much control are drawn in the main form(I mean when form is loaded on the first time).I already told that, the above mentioned number of control is only an example. Some time it may decrease or increase. If i go for some optimization here in my design part then it won't serve users purpose. Clearly i am into trouble. What i can optimise is my code not design.
Is there any way to hadle this situation.
Sreejith Nair
|
|
|
|
|
sreejith ss nair wrote:
I have near to 100-150 labels and same number of textboxes in a my main form.And this form also contain few other controls. Say panel, combo box etc.
That sounds like a very cluttered form. It sounds to me like you should be thinking of redesigning that so that there are less controls, by moving some to subordinate forms of some kind.
sreejith ss nair wrote:
If i go for some optimization here in my design part then it won't serve users purpose. Clearly i am into trouble. What i can optimise is my code not design.
You should think very carefully about your user interface, because, even if you do improve the speed, your form, with that many controls, is likely to overwhelm your users.
Do you want to know more?
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
|
|
|
|