|
Another thing that wasn't mentioned is that properties are integral with serialization, and with design time processes which allow us to interact with objects in the visual development environment. These purposes too establish when and how to use properties (together with attributes).
|
|
|
|
|
Hi all,
I read data from a database, fill a datagrid with them and create an XML-File via datagrid.RenderControl()
So I get an XML-file with extension xls, which Excel can read.
But with some field values Excel gets lost.<br />
<br />
Example of such a file (save as test.xls):<br />
<table cellspacing="0" rules="all" border="1" id style="border-collapse:collapse;"><br />
<tr><br />
<td>Text</td><td>Date</td><td>Value1</td><td>Value2</td><br />
</tr><br />
<tr><br />
<td>First</td><td>2006-01-26</td><td>0</td><td>0</td><br />
</tr><br />
<tr><br />
<td>+Second</td><td>2006-01-26</td><td>0</td><td>0</td><br />
</tr><br />
<tr><br />
<td>Third</td><td>2006-01-26</td><td>0</td><td>0</td><br />
</tr><br />
</table>
The first line shows okay in Excel, but after the '+'-Sign in the second line all date- and numberfields are shown as text fields. Now for calculations all first have to be converted.
Does anyone know how to avoid this problem?
Thank you!
Martin
2B||!2B?
|
|
|
|
|
Windows controls have BringToFront() and SendToBack() methods, but is there a property that gives you access to the Z index? Or do I need to keep track of it myself? Reason I ask, I want to save the state of movable controls so I can restore that state. Anybody dealt with this?
|
|
|
|
|
I see, BringToFront and SendToBack change the index of the Controls collection. Their order in the collection is their Z order.
|
|
|
|
|
Each control should have a TabIndex on it. Each control should also have a TabStop property. This should control what the tab order is on your windows form.
By the way, to initially set this tab order there is a cool thing you can do in Visual studio. Open up your form. Then go to View Tab Order. This will show numbers next to all the controls on your form. At that point you can start to click on controls and re-set the tab order to a different order. Hit the esc key when done. Anyway, I think that is a cool feature.
Hope that helps.
Ben
|
|
|
|
|
What I have is a few picture boxes that you can drag around the form. When you click on one, it's brought to the front. So I need to keep track of what is supposed to be on top of what. I'm not sure that tab index would give me the correct data for this situation.
But thanks for the suggestion. I had seen the View Tab Order dialog before, but forgot it was there. Definitely good to know.
|
|
|
|
|
I'm a noob to C#, so bear with me.
I have the following class and form:
<br />
using System;<br />
using System.Collections.Generic;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Data.SqlClient;<br />
using System.Drawing;<br />
using System.Text;<br />
using System.Windows.Forms;<br />
<br />
namespace tracker<br />
{<br />
public partial class frmMain : Form<br />
{<br />
SqlConnection objDBConnection;<br />
SqlDataAdapter objDBAdapter;<br />
DataSet objDBDataSet;<br />
DataGridView objDBGridView;<br />
<br />
public frmMain()<br />
{<br />
InitializeComponent();<br />
}<br />
<br />
private void frmMain_Load(object sender, EventArgs e)<br />
{<br />
this.objDBConnection = new SqlConnection("Server=BigHouse;Database=tracker;Trusted_Connection=yes");<br />
try<br />
{<br />
this.objDBConnection.Open();<br />
this.toolStripStatusLabel1.Text = "Connected to Tracker database";<br />
}<br />
catch (Exception connerr)<br />
{<br />
this.toolStripStatusLabel1.Text = "Cannot connect to Tracker database";<br />
}<br />
<br />
<br />
this.getProjectGridData();<br />
<br />
<br />
DataRow r = this.objDBDataSet.Tables["tbl_projects_main"].Rows[0];<br />
Console.WriteLine("num records = " + <br />
this.objDBDataSet.Tables["tbl_projects_main"].Rows.Count + <br />
" and " + <br />
r["prj_name"].ToString());<br />
<br />
<br />
this.objDBGridView = new DataGridView();<br />
this.objDBGridView.DataSource = this.objDBDataSet.Tables["tbl_projects_main"];<br />
this.objDBGridView.AutoGenerateColumns = true;<br />
this.objDBGridView.Location = new Point(0, 0);<br />
this.objDBGridView.Size = new Size(700, 490);<br />
this.objDBGridView.MinimumSize = new Size(700, 490);<br />
this.objDBGridView.BackgroundColor = System.Drawing.Color.AliceBlue;<br />
this.objDBGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);<br />
<br />
this.objDBGridView.Visible = true;<br />
}<br />
<br />
private void getProjectGridData()<br />
{<br />
string strSql;<br />
strSql = "SELECT * FROM dbo.tbl_projects_main";<br />
this.objDBDataSet = new DataSet();<br />
this.objDBAdapter = new SqlDataAdapter();<br />
this.objDBAdapter.SelectCommand = new SqlCommand(strSql, this.objDBConnection);<br />
this.objDBAdapter.Fill(this.objDBDataSet, "tbl_projects_main");<br />
}<br />
}<br />
}<br />
I know I'm getting records and info back from the database, but nothing shows up on my form - no datagridview to be seen anywhere.
Any help is appreciated.
|
|
|
|
|
I am pretty sure you need a databind after you set the datasource.
Ben
|
|
|
|
|
As far as I can see, you do all the data stuff fine, but you never actually add the datagridview to the form itself. Try this.Controls.Add(objDBGridView);
|
|
|
|
|
Thanks to both of you. The real kicker was this.Controls.Add(objDBGridView). I had looked at that before and thought, "Nah. Couldn't be."
Well, I was wrong.
Thanks!
|
|
|
|
|
The fact that you're using the DataGridView means you're using VS.Net 2005. The designer is really helpful in setting up datagridview columns and formatting if you need anything beyond basic formatting and display. Check that out if you get a chance.
|
|
|
|
|
Can someone please tell me: How to run an application on a remote computer (on the same LAN)????
// This, I think will run my notepad on my machine
Process.Start("notepad", "C:\\Windows\\notepad.exe");
// This, I think will run that remote machine's notepad on my machine.
Process.Start("notepad", "\\\\remote-machine-name\\C$\\Windows\\notepad.exe");
// But how to run that remote machine's notepad on that remote machine.... ????
Thanks for your time ..
|
|
|
|
|
The first thing that comes to my mind, if you want to do this in C# is to make a client and a server. The server being at the remote end which executes processes as instructed by the clients. Or you could use PsExec.
|
|
|
|
|
Thanks for your reply.
You are right. I am basically building client server applications.
Now, what I want to do is that:
1) Execute the server on my machine.
2) Through that server, initialize/execute the clients(.exe) on the client machines.
3) Clients will then start communication with the server.
I actually need help with that 2nd step.
PsExec looks to be interesting, and I will play with it tomorrow and see if that will serve the purpose. But i guess, in this case, I will have to use PsExec instead of my server to initialize the client applications.
Thanks.
Sarfraz
|
|
|
|
|
Anyone who could guide me a little please.....
Thanks....
Sarfraz.
|
|
|
|
|
I have the following classes defined:
public class ControllerPage : System.Web.UI.Page
{
protected long m_nStatusCode;
long PropStatusCode(value)
{
get { return m_nStatusCode; }
set { m_nStatusCode = value; }
}
}
public abstract class DerivedPage : ControllerPage
{
}
public partial class MyPage : DerivedPage
{
public void MyFunction()
{
this.StatusCode = 1;
if (this.StatusCode == 1)
{
}
}
}
I can set the property from the MyPage class, and I can see it being set i the debugger, but when I try to retrieve the value, I don't get anything back. Before I start declaring C# to be one of the most insanely unusable languages I've ever had the displeasure to use, can someone please tell me why this is happening?
I've looked around on the web, but I haven't found a single place that talks about inheritance more than one-class deep.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: but when I try to retrieve the value, I don't get anything back.
This is ASP.NET... are you familiar with the round-tripping in Web Applcations. MyPage is instantiated each trip back to the server. You have to account for the "state" of the variable if you want it to persist across round trips.
led mike
|
|
|
|
|
i hate web programming
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: i hate web programming
Join the club... we are having Jackets made.
led mike
|
|
|
|
|
Where can I order mine?
|
|
|
|
|
What color is the jacket?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: What color is the jacket?
That's a silly question... all colors from the Web Pallet are available of course.
led mike
|
|
|
|
|
For a start, your syntax isn't right. You refer to StatusCode - have you set this as a property somewhere in your ControllerPage class? All I see there is a method called PropStatusCode, which won't compile BTW because you have applied a parameter to it, so it's no longer a property. (Check the other part of your partial MyPage class, because I think that you might have declared StatusCode in there. )
I regularly use classes where the inheritance chain runs more than 1 level deep and I have no problems with it.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I actually can't see how this even compiles:
John Simmons / outlaw programmer wrote:
long PropStatusCode(value)
{
get { return m_nStatusCode; }
set { m_nStatusCode = value; }
}
That mixes property and method declarations up.
Also:
John Simmons / outlaw programmer wrote: this.StatusCode = 1;
Does not equal
John Simmons / outlaw programmer wrote: long PropStatusCode(value)
There is an additional Prop prefix on Status code in the base class.
|
|
|
|
|
Well, I didn't do a copy paste from the code, so ignore the errors... In any case, the real problem is that I forgot that variables don't persist between page loads. Of course - why would they? That would make web programming too much like regular application programming, and we don't want that, now, do we...
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|