|
Member 11189395 wrote: i have this...but when I run it... i keeps printing twice some sentences... I hate to disappoint you, but that is not C#.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I have created c#.net desktop application in VS2012 with localDB.
now for deployment is it necessary to install sqlexpress or sql server at client pc ??
what exact steps for deployment.
I have also use crystal report in it, so how to deploy that crystal report also work properly.
-- modified 29-Oct-14 14:24pm.
|
|
|
|
|
You do not install SQL Server or SQL Express. If the user already has a SQL Server database, you should let them install into that installation rather than trying to force a one in there for them. If they choose to install, you can include the Express version as a redistributable that is triggered out of your install (the full version of SQL Server is not a redistributable). To be honest, you really should be considering looking at using a professional grade installation package, as this will make working out things like prerequisites much easier.
|
|
|
|
|
client has not install sql server so basically i have to install sql express ?
because i tried to run setup without installing sql express at client side but its not working
|
|
|
|
|
If you want to use a multiuser database in you application, then SQL server (express edition or teh full monty) is the way to go: but it come with a cost - and a pretty big one. SQL server is a big complicated package, and it isn't something you should expect the "average joe" to install. Heck, I have to Google for instructions every time I do it because it is horribly easy to get get it wrong!
Even asking the user if he needs it probably indicates you are doing something wrong: if two users in the same company install your software, you probably want them to share the data - they are not likely to know if it is installed, so they will probably install a new version - and then there is no data sharing!
If you app can use the database as a single user, then think carefully about if you actually need SQL server at all: SQLite, SQLCE, or even Access can handle 90% or more of what SqlServer can do for a single user, without needing a big, slow, cumbersome server installation (a couple of DLLs is all you need).
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Access to Form1 data label1.Text?
using abc;
namespace WindowsForm
{
class Form1:Form
{
private label Label1;
}
}
using Form1;
namespace abc
{
class classtest
{
public method1
{
Form1.label1.Text="text";
}
}
}
modified 29-Oct-14 11:45am.
|
|
|
|
|
What happens when you try it?
|
|
|
|
|
You seriously need to read this[^].
You import namespaces, not classes (expect in special cases). Your "using" statement is worthless and should be removed.
Also, Your class files shouldn't know ANYTHING at all about a Form. Your data should be stored in classes and the forms should reference that data, not the other way around, like you're doing.
modified 29-Oct-14 12:03pm.
|
|
|
|
|
Yes, but has to be some ways to get access from child to parent in OOP.
|
|
|
|
|
That's actually a violation of OOP principles. No "child" object should know anything about its parent container. Doing so very tightly couples the two classes together to the point that they cannot be used separately in other projects.
|
|
|
|
|
Okay, if the question you are asking is why can you not access the Text property of Form1.label1, there are many problems with your code. Some are code bugs, while others are architectural. Let's start with the code bugs in your example:
1. Form1 is not public. This means that it will not be seen outside the WindowsForm namespace.
2. Even if Form1 was public, you haven't instantiated it anywhere.
3. Assuming you manage to instantiate Form1, Label1 is private, so cannot be accessed outside of Form1.
4. You have a mismatch between the case of Label1 and label1.
5. Assuming that Form1 and Label1 were public, Label1 has not been instantiated, so it cannot be used anywhere as the Windows Forms Label control (I'm guessing that's what this is), is not a static class. So, you would need to instantiate it.
6. method1 is missing the scope and parentheses.
Okay, now let's get to the big architectural issue.
You are attempting to manipulate a control on another form from method1. This is a big OO violation. You aren't just exposing the text property of the label, you're exposing all the other properties that the Label has made public. The standard way to deal with this would be to expose something inside Form1 that can be used to set this value without exposing the control that's consuming it. You might end up with something like this:
namespace WindowsForm
{
public class Form1 : Form1
{
private Label Label1;
public string LabelText
{
get { return Label1.Text; }
set { Label1.Text = value; }
}
}
}
namespace abc
{
class classtest
{
public void method1()
{
Form1 form = new Form1();
form1.LabelText = "text";
}
}
} By the way, it's a good idea to rename your controls to be something more meaningful.
|
|
|
|
|
Pete O'Hanlon wrote: Form1 is not public. This means that it will not be seen outside the WindowsForm namespace.
Technically, that should be outside of the assembly which contains the class. Other classes in a different namespace within the same assembly would still be able to access it.
However, that's probably a bit too advanced for the OP at the moment.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Problem with access from child ro parent class has to have some solution. Especially in multy file project
|
|
|
|
|
Thank you. I've got it. Actually excellent involving and understanding.
modified 30-Oct-14 11:01am.
|
|
|
|
|
Good for you. That's excellent.
|
|
|
|
|
Now its working, but don;t change label1.Text. I think problem is in second instance of Form1. label1 is changing only second instance. But shown are first instance and label1 is in first instance.
Problem 2 - Two side or class on class declaration.
PS. Namespaces are in different files in project. New file is included in project with "Add exist element" and use with "using" with both side declaration.
using NamespaceTest;
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public string LabelText
{
get { return Label1.Text; }
set { Label1.Text = value; }
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("Button was pressed");
ClassTEST d = new ClassTEST();
d.Changelabel();
}
..
And added file
using System;
using WindowsFormsApplication3;
namespace NamespaceTest
{
public class ClassTEST
{
public void Changelabel()
{
Form1 form = new Form1();
form.LabelText = "text";
}
}
modified 30-Oct-14 12:30pm.
|
|
|
|
|
Post this section of code please.
|
|
|
|
|
I fix it. It's working, but still no result, don't change label1.Text.
But look how strange are both classes calls -on each other class calls.
modified 30-Oct-14 12:47pm.
|
|
|
|
|
The issue here is that you are creating a new instance of Form1 in your Changelabel method. So, you have one instance of the form which allows the user to press the button. They then press it and it creates an instance of ClassTEST. In that class, you create a new instance of Form1 and you call LabelText on that new instance (which won't be visible because you aren't showing it). If you want to work with the original instance, you're going to have to change a couple of things:
public void Changelabel(Form1 form)
{
form.LabelText = "text";
} and
private void button1_Click(object sender, EventArgs e)
{
new ClassTEST().ChangeLabel(this);
}
|
|
|
|
|
YES!Works.Many thanks.Second week i was searching way to do it.
PS.But i suspect problem is not fully fixed for all cases.
|
|
|
|
|
|
In example child ->parent i found parent-> child. So there are 2 examples parent->child
|
|
|
|
|
The DGV is bound to a table. I have an inserted TextBoxColumn which is meant to display values from a related table.
I have my grid displaying nicely, with the empty text box column.
I have the values to insert into the grid.
But when do I do it? With which event handler?
I saw a suggestion to use DataBindingsComplete, but the column hasn't been inserted by the time that is called.
EDIT: Just had a thought. Don't auto-generate the columns. Manually create all the columns. Then add the rows, one-by-one, populating the columns as I go.
|
|
|
|
|
Nigel Mackay wrote: With which event handler? Depends on "how" you'd want to do so. One option would be the CellFormatting[^] event. Get's called whenever the value of a cell is needed. Check if the cell is in the last column, and if so, fetch the value - otherwise, display the default.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Yes, that would work. In fact it rings a bell from many years ago, along with CellValueNeeded and CellValuePushed.
Because I only have 2 bound and 1 unbound column and the grid is Read Only I created the grid manually. That way I can populate the grid while it is being built.
|
|
|
|