|
You can put your data in a dataset at runtime and then set the datasource of crystal report to that DataSet dynamically !
[ _ Always there is another way _ ]
|
|
|
|
|
How do you recieve input from a user on a console?
|
|
|
|
|
try following
string myValue;
myValue = Console.ReadLine();
- ashish
|
|
|
|
|
hi,
I am making Windows Service(User defined)
I have written code inside OnStart within Windows Service
Inside the onstart i want that suppose a.exe is already running
I want to close that a.exe and start a.exe from windows Service
When i run the windows Service two exe runs cocuurently.
On Start i have written
Process.Start(@"c:\a.exe");
I want to identify in beginning of any process of a.exe if exist
how can i check in windows service OnStart()
protected override void OnStart(string[] args)
{
// TODO: Add code here to start your service.
Process[] aProcesses1;
if (aProcesses1.Length > 0)
{
if(rd1==true)
{
// The last excel process is the orphaned process which is killed
aProcesses1[aProcesses1.Length-1].Kill();
rd1=false;
}
}
int intExcelPID;
aProcesses1=Process.GetProcessesByName("a");
string strProc="These are the processes running \n";
for (int i = 0; i <= aProcesses1.GetUpperBound(0); i++)
{
intExcelPID = aProcesses1[i].Id;
strProc+=intExcelPID.ToString()+ " ";
}
//Retrive from registry the value of Path
RegistryKey hklm =Registry.LocalMachine;
hklm=hklm.OpenSubKey("SOFTWARE\\man");
Object obp=hklm.GetValue("Path");
string file=obp.ToString() + "\\man.exe";
Process.Start(@file);
}
Thanks
sanjeev
|
|
|
|
|
|
hi,
I am making Windows Service(User defined)
I have written code inside OnStart within Windows Service
Inside the onstart i want that suppose a.exe is already running
I want to close that a.exe and start a.exe from windows Service
When i run the windows Service two exe runs cocuurently.
On Start i have written
Process.Start(@"c:\a.exe");
I want to identify in beginning of any process of a.exe if exist
how can i check in windows service OnStart()
protected override void OnStart(string[] args)
{
// TODO: Add code here to start your service.
Process[] aProcesses1;
if (aProcesses1.Length > 0)
{
if(rd1==true)
{
// The last excel process is the orphaned process which is killed
aProcesses1[aProcesses1.Length-1].Kill();
rd1=false;
}
}
int intExcelPID;
aProcesses1=Process.GetProcessesByName("a");
string strProc="These are the processes running \n";
for (int i = 0; i <= aProcesses1.GetUpperBound(0); i++)
{
intExcelPID = aProcesses1[i].Id;
strProc+=intExcelPID.ToString()+ " ";
}
//Retrive from registry the value of Path
RegistryKey hklm =Registry.LocalMachine;
hklm=hklm.OpenSubKey("SOFTWARE\\man");
Object obp=hklm.GetValue("Path");
string file=obp.ToString() + "\\man.exe";
Process.Start(@file);
}
Thanks
sanjeev
|
|
|
|
|
Going back to your original post, I already pointed out HUGE problems with your code, that by looking at this post, you haven't fixed at all.
But, to find all the "a" processes and kill them, then restart a new one:
Process[] foundProcs = Process.GetProcessesByName(@"a");
foreach (Process proc in foundProcs)
{
proc.Kill();
}
Process.Start(@"notepad");
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
having problems with the following:
treeView1.Nodes.Clear();
treeView1.Nodes.Add(dbName);
treeView1.TopNode.ImageIndex = 0;
treeView1.TopNode.SelectedImageIndex = 0;
and then later:
while (dataReader.Read())
{
TreeNode dbNodes = new TreeNode();
dbNodes.Tag = dataReader.GetValue(0).ToString();
dbNodes.Text = dataReader.GetString(0);
treeView1.TopNode.Nodes.Add(dbNodes);
treeView1.ExpandAll();
}
i'm getting the following error:
object refrence not set to an instance of an object
and it fails on the bold lines, if I comment out the first spot it errors then I fail on the second bold.
any ideas? what am i doing wrong?
|
|
|
|
|
Topnode is the first 'fully visible' node in the tree, not necessarily the first or root node. If no node is visible (the only one is scrolled out of sight) then topnode will return null. Try using FirstNode instead. That is the first child node in the nodes collection regardless of visibility...
Absolute faith corrupts as absolutely as absolute power
Eric Hoffer
The opposite of the religious fanatic is not the fanatical atheist but the gentle cynic who cares not whether there is a god or not.
Eric Hoffer
|
|
|
|
|
i must not have something right, as i'm recieveing the same error on the following:
treeView1.TopNode.FirstNode.ImageIndex = 0; treeView1.TopNode.FirstNode.SelectedImageIndex = 0;
and if i comment those out i still error out on this one
treeView1.TopNode.FirstNode.Nodes.Add(node);
|
|
|
|
|
Come on, finding out which element is null isn't that hard.
A NullReferenceException always tells you that something is null , but you want to access a property or method anyway.
In your code there are only 3 possibilities: treeView1 , treeView1.TopNode or treeView1.TopNode.FirstNode .
Use the debugger to find out which one is null and you're done.
Probably you've created TreeNodes but didn't add them to the TreeView...
Regards,
mav
|
|
|
|
|
Believe it or not there was something wrong with the way I had it typed up, because i began changing things around and ended up swapping out dbnode and dbnode1 and it works (well, sorta) and if i swap them back out meaning make dbnode1, dbnode then it doesn't work...not sure why, but it works so i'm not worried about it any more....
|
|
|
|
|
Can i just create a class or struct just for hold a set of static datas, let say objMonth contain two properties Month_Desc(String) and Month_ID (number). So Later when i just need to issue the command : cboMonth.DataSource = "objMonth".
The combobox will be able to display Jan till Dec. Thanks.
|
|
|
|
|
The comboBox has a property called 'DisplayMember' which tells it which property on the object it binds to is the one to display. It needs to be a property from memory ( not a public variable ).
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I think my poor english make u misundestand.
I've code below in my form ...
<br />
private struct MonthList<br />
{<br />
public MonthList(string desc,string monthNo, string shortdesc)<br />
{<br />
this._desc = desc;<br />
this._number = monthNo;<br />
this._shortdesc = shortdesc;<br />
}<br />
<br />
private string _desc;<br />
private string _number;<br />
private string _shortdesc;<br />
<br />
public string monthDesc<br />
{<br />
get {return _desc;}<br />
}<br />
<br />
public string monthNo<br />
{<br />
get {return _desc;}<br />
}<br />
<br />
public string shortDesc<br />
{<br />
get {return _shortdesc; }<br />
}<br />
}<br />
<br />
private void init_cboMonth()<br />
{<br />
ArrayList month = new ArrayList ();<br />
<br />
month.Add( new MonthList ("January","1","Jan"));<br />
month.Add( new MonthList ("Feburay","2","Feb"));<br />
month.Add( new MonthList ("March","3","Mar"));<br />
month.Add( new MonthList ("April","4","Apl"));<br />
month.Add( new MonthList ("May","5","May"));<br />
month.Add( new MonthList ("June","6","Jun"));<br />
month.Add( new MonthList ("July","7","Jly"));<br />
month.Add( new MonthList ("August","8","Aug"));<br />
month.Add( new MonthList ("September","9","Sep"));<br />
month.Add( new MonthList ("Otocber","10","Oct"));<br />
month.Add( new MonthList ("November","11","Nov"));<br />
month.Add( new MonthList ("December","12","Dec"));<br />
<br />
this.comboMonth.DataSource = month;<br />
this.comboMonth.DisplayMember = "monthDesc";<br />
this.comboMonth.ValueMember = "monthNo";<br />
<br />
}<br />
It work fine in the form..
by when i try to seperate code above it to another file like below
<br />
public class stdData<br />
{<br />
public static ArrayList getMonthList()<br />
{<br />
ArrayList month = new ArrayList ();<br />
month.Add( new MonthList ("January","1","Jan"));<br />
month.Add( new MonthList ("Feburay","2","Feb"));<br />
month.Add( new MonthList ("March","3","Mar"));<br />
month.Add( new MonthList ("April","4","Apl"));<br />
month.Add( new MonthList ("May","5","May"));<br />
month.Add( new MonthList ("June","6","Jun"));<br />
month.Add( new MonthList ("July","7","Jly"));<br />
month.Add( new MonthList ("August","8","Aug"));<br />
month.Add( new MonthList ("September","9","Sep"));<br />
month.Add( new MonthList ("Otocber","10","Oct"));<br />
month.Add( new MonthList ("November","11","Nov"));<br />
month.Add( new MonthList ("December","12","Dec"));<br />
return month;<br />
}<br />
}<br />
<br />
private struct MonthList<br />
{<br />
public MonthList(string desc,string monthNo, string shortdesc)<br />
{<br />
this._desc = desc;<br />
this._number = monthNo;<br />
this._shortdesc = shortdesc;<br />
}<br />
<br />
private string _desc;<br />
private string _number;<br />
private string _shortdesc;<br />
<br />
public string monthDesc ...<br />
public string monthNo ...<br />
public string shortDesc ...<br />
}<br />
in the form ..
<br />
private void init_cboMonth()<br />
{<br />
stdData stdData = new stdData();<br />
ArrayList month = stdData.getMonthList();<br />
<br />
this.comboMonth.DataSource = month;<br />
this.comboMonth.DisplayMember = "monthDesc";<br />
this.comboMonth.ValueMember = "monthNo";
}<br />
So what is goinf wrong ? thanks.
|
|
|
|
|
kakarato wrote:
So what is goinf wrong
Simple, you defined getMonthList() as static, but then tried to call it on an instance
stdData stdData = new stdData();<br />
ArrayList month = stdData.getMonthList();<br />
<br />
this.comboMonth.DataSource = month;<br />
this.comboMonth.DisplayMember = "monthDesc";<br />
this.comboMonth.ValueMember = "monthNo";
try this instead
this.comboMonth.DataSource = stdData.getMonthList();<br />
this.comboMonth.DisplayMember = "monthDesc";<br />
this.comboMonth.ValueMember = "monthNo";
|
|
|
|
|
Thanks for help but an Error Message come out at the same line. The error message is :
"Could not bind to the new display member."
If i take out the line "this.comboMonth.ValueMember="monthNo"
something strange is display in the combo box ..
In the combox box it will display "XYZ.Model.Monthlist",
where the XYZ.Model is the namespace.
<br />
this.comboMonth.DataSource = stdData.getMonthList();<br />
this.comboMonth.DisplayMember = "monthDesc";<br />
|
|
|
|
|
Hi, how can I access, windows forms properites by other thread than the form.
I have this exception when try to read or modify an lisview property:
InvalidOperationException.
Cross-thread operation not valid: Control 'MyListView' accessed from a thread other than the thread it was created on.
La realidad no es más que impulsos eléctricos del cerebro - Morpheus
|
|
|
|
|
You need to ask the main form thread to access the control for you.
For example, to add a text entry into MyListView, do something like the following:-
public class MyForm : System.Windows.Forms.Form {
private System.Windows.Forms.ListView MyListView;
...
[STAThread]
static void Main() {
Application.Run (new MyForm());
}
private void AddItem (string text) {
MyListView.Items.Add (text);
}
private delegate void AddItemHandler (string text);
private void AddItemFromAnotherThread (string text) {
AddItemHandler method = new AddItemHandler (AddItem);
object[] args = new object[] {text};
this.Invoke (method, args);
}
}
> whoami
The system is unable to identify you when you don't even know your name!
|
|
|
|
|
Thank you!
La realidad no es más que impulsos eléctricos del cerebro - Morpheus
|
|
|
|
|
Hello,
I have made a program which searches for statements in source files. The problem which I encoutered was when loading a string from a file using ReadToEnd(), which I need to search using reg expressions. The file that I read is 6mb, but the memory used by the program increases with 30mb while I execute the line calling the method. One reason is that I'm in debug mode, but it's still too much. Also I had an earlier version of the program where I read the file line by line and it didn't use that much memory. What could be the reason for this strange behavior?
Thanks
|
|
|
|
|
The .NET Frameworks Memory Manage RESERVED that much memory for your application. It doesn't mean your actually using it.
If you want to get the real numbers, you'll have to use the Performance Monitor and the .NET Framework performance counters.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I am trying to save what image has been selected to be put in a picture box, but when I use this code:
string szsavepic = pbPicture.Image.ToString();
it returns:
System.Drawing.Bitmap
Help please, it is appriciated(Spell Check?)
|
|
|
|
|
As far as I know, the Image and Bitmap objects do not store the file name.
What you can do, however, is set the tag of the Bitmap to the file name, then retrieve that tag at a later date:
string fileName = "hello.jpg";
Bitmap myBitmap = new Bitmap(fileName);
myBitmap.Tag = fileName;
pbPicture.Image = myBitmap;
Bitmap imageInPictureBox = (Bitmap)pbPicture.Image;
string theFileName = (string)myBitmap.Tag;
Further, you could put the file name and image in some dictionary/hashtable for easy use...but the above code should work fine for you with little overhead.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Homosexuality in Christianity
Judah Himango
|
|
|
|
|
How can I do this for many images?
|
|
|
|