|
Thanks.
But you said the way can achieve at startup only.
If program has run, how send parameter?
|
|
|
|
|
jason_mf wrote: But you said the way can achieve at startup only.
If program has run, how send parameter?
Didnt got that.
|
|
|
|
|
Because my winform program can run only instance.
So I checked in main of program class.
if there is a instance in proceeding, can I get the main form of this instance?
Or other way?
|
|
|
|
|
What kind of information are you trying to pass, and when?
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
Anther program will call my winform program, then open a form (is not MainForm ).
the caller will send a string to my winform.
when the caller calls, my winform maybe has run, or does not run.
|
|
|
|
|
If the program is already running you still send the parameter the same way, the constructor. The only difference is that Application.Run() won't be calling that constructor. You will have to call it yourself, how is up to you.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
first get the form.
then set property of the form.
can it achieve ?
But I can not get the form.
|
|
|
|
|
Hi I have an object I need to serialize in XML.
In my object I have some decimal fields that in the XML file must (MUST) appear with 2 decimals.
Is there a way to tell the serializer he must format all decimal that way?
Life is not short... the problem is only how you organize yourself
|
|
|
|
|
Can I change windows time & date with C#?
Mahdi 82161021
|
|
|
|
|
|
I doubt your users want you messing with their clocks.
|
|
|
|
|
Hi,
I have 3 sql tables.
1.deptmaster
-dptid(PK)
-dptname
2.deptassignment
-dptid(FK)
-rptid
-frequencyid
3.rptmaster
-rptid(PK)
-other rows
4.rptfreqmaster
-freqid
-freqname
I want to show values from table in given below form in treeview control.(I am using c#.net web application)
-Reports
--Department
---ReportName
scenario: 1 onclick of Reports in tree view I want to get all dept from table.
2 on click of Department in tree view I want to get all reports name in this department.
please give me the solution ASAP
its urgent.
With Regards
Ashish K. Vyas
|
|
|
|
|
Hi,
Project
-------
I have this list box that will get a list of items from a database. Upon choosing an item, it will populate the DataGridView with the data, this data is different for different items, e.g. one might have a size field and another wouldn't or an item might have 5 entries but another 9, etc. This populated data is from a table that has a unique ID (key), the field name, the field value and the foreign key to link to the item table.
Problem 1
---------
Currently, I'm trying to add an item into the database, how can I create a DataGridView that would allow me to add rows to it. If I bind it to a table I get the error that table.rows.add() is not allowed on a bound DataGridView.
I have to presume that I can just unbind the table and add the rows of data manually. I'm wondering if there is an easier way of doing it.
Problem 2
---------
Further to the above, if I want to edit an item, how can I go about adding a new row if the columns are bound. I require (during editing) that columns because more than 1 user might be editing the same item at the same time.
How would I go about doing this?
Anyone has any article to point me to?
Thanks.
Desmond
|
|
|
|
|
Answer to problem 1
-------------------
1. Add a datagridview to your form.
2. Dont add any column to it
add a quote to retrieve data from the database
1. connectionstring
e.g string conStr="Add the relevent connection to the database"
2. a function to retrieve the data. Create a class called it DataAccess
<code>
using system.data;
using system.data.oleddb;
public class DataAccess
{
public void Show(string sql, string con, datagridview dt)
{
}
}
</code>
Then you can call this class to pupulate any datagridview with any number of rows or columns without any modifications. If you want a complete quote let me know (lnkgoeng@webmail.co.za)
|
|
|
|
|
Hi all!
I´m trying to make a barcodeprinting and to make it possible i have to have a page foreach items in my listview.
my code look like this:
private void button1_Click(object sender, EventArgs e)
{
if (checkBox1.Checked == true)
{
PrintDialog theDialog = new PrintDialog();
theDialog.Document = printDocument1;
if (theDialog.ShowDialog() == DialogResult.OK)
{
printDocument1.DocumentName = listView1.Items.Count.ToString();
printDocument1.PrintPage += new PrintPageEventHandler(this.printDocument1_PrintPage);
printDocument1.Print();
}
}
}
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
foreach (ListViewItem lvi in listView1.Items)
{
DateTime dt = DateTime.Now;
string doktyp = "278";
Font font = new Font("3 of 9 Barcode", 20);
int St = Convert.ToInt32(domainUpDown1.Text);
Font font1 = new Font("Arial", St);
Font font2 = new Font("Arial", 10);
float x = 120;
float y = 100;
e.Graphics.DrawString("Jobb: " + label11.Text, font2, new SolidBrush(Color.Black), x + 500, y - 50);
e.Graphics.DrawString("Användare: " + label12.Text, font2, new SolidBrush(Color.Black), x + 500, y - 35);
e.Graphics.DrawString(dt.ToString("yyyy-dd-MM HH:mm:ss"), font2, new SolidBrush(Color.Black), x + 500, y - 20);
e.Graphics.DrawString("*" + lvi.SubItems[1].Text + "*", font, new SolidBrush(Color.Black), x, y + 85);
e.Graphics.DrawString("*" + lvi.SubItems[1].Text + "*", font, new SolidBrush(Color.Black), x, y + 105);
e.Graphics.DrawString("*" + lvi.SubItems[1].Text + "*", font, new SolidBrush(Color.Black), x, y + 125);
e.Graphics.DrawString(lvi.SubItems[1].Text, font1, new SolidBrush(Color.Black), x, y + 145);
}
}
With this code it overwhrites all the items in one page.
Thanks!
Best Regards André
|
|
|
|
|
Well, that's what you're telling it to do. You don't actually set x anywhere that I can see. It looks to me like all your labels will print in one location, because that's what your code does. x and y need to change to move your labels.
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
yes i know.. but i want it to be on print page2 in the same position like page1.
Regards!!
|
|
|
|
|
In c#.net which namespace and classes and method use to control the hardware of my computer i,e i want to develop a c# program which can use for eject the cd rom of my computer without and manualy touch.if possible plz sent a demo program to understand the uses of namespace,classes and method .
|
|
|
|
|
You need to read up on how to ask questions. About C#.NET is not a worthwhile header.
There are namespaces that may help you, but I suspect you're going to end up pinvoking C APIs www.pinvoke.net[^] is a good place to start
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
Hi,
I have started looking at LINQ lately...
I can see that learning LINQ will indeed reduce the coding I do at present...
Questions:
1)
Do you think LINQ is the way forward? Will it be in demand in the near future?
2)
It's just that I do not see or hear any projects requiring the knowledge of LINQ.
So, should I really invest more time to learn LINQ? I do not miind doing this if I know it will be in demand...
Thanks
|
|
|
|
|
1 - LINQ is probably resume fodder, and will most likely be used for all sorts of things it's not good for, before things settle down and it just becomes a tool in the toolbox.
2 - I can't percieve of a project NEEDING LINQ. It's just syntactic sugar. There are good reasons not to use it ( one, if you're the only one on a team who can read the code ). But, I still am trying to carve out time to know it better and to be able to use it myself.
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
For the most part, I agree with what Christian said.
1. LINQ is still very new and all of the guidance around when it should be used isn't in place yet. There is a lot of power and flexibility behind LINQ and the concepts taht are in place to support it, like extension methods and lambda expressions. Most of those language features will eventually just become another tool, in the same way foreach has.
2. There will never be a project that requires LINQ. Everything that can be accomplished using LINQ can be accomplished in more traditional manners as well, although it may be easier using LINQ or some of the LINQ related language features.
In my opinion, you're better off knowing how the supporting language features work (extension methods, lambdas, inferred typing, and object initializers) and what you can do with them. LINQ is a pretty big topic (LINQ to SQL, Entities, XML, etc...) but the supporting features are all the same no matter what.
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
[ Blog][ Articles][ Forum Guidelines] Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
|
|
|
|
|
Not really important, but I'm just curious.
Say that you want to print something to a log if a global boolean (condition) variable is set.
How would you do it?
1)
if(condition)<br />
CallLogMethod("Message");
OR
2)
CallLogMethod("Message");
and in the method body put
if(!condition)<br />
return;
The first makes the code more bloated if used intensively, while the second uses the call stack even though it might not do anything.
So how would you do it?
|
|
|
|
|
I'd go with 2. My dual core CPU can handle it. My number 1 priority is bug free code that's easy to use.
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
There is a third option:
CallLogMethod(condition, "Message") The CallLogMethod still evaluates the condition, but it gets passed in. This is similar to how Debug.WriteLineIf works.
In either case, I would go with option 2 or 3 and push the test into the method itself. This way, you guarantee that it will always be tested and tested the same way and it's one less thing to worry about at the calling site.
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
[ Blog][ Articles][ Forum Guidelines] Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
|
|
|
|
|