|
Hi all,
I have a button click event that is used to write a double used for offsetting another number in a form (ultimately to zero a display). Still struggling as a new user and having problem with an error:
'double WindowsApplication14.frmMain.btnZero_Click(object, System.EventArgs)' has the wrong return type
Here is the function:
private double btnZero_Click(object sender, EventArgs e)
{
dblOffset = dblReceive * -1;
return dblOffset;
}
Can anyone let me know what I'm doing wrong here?
Thanks.
|
|
|
|
|
you cant use return type for click event.
you should use void for click event.
the signature of method that you can use for click event is:
void methodname(object,EventArgs)
|
|
|
|
|
Do you have any suggestion for how I would get around this? Need to look at the current value of a double and then null it by clicking a button labeled "Zero". That is why dblOffset is equal to dblReceive * -1. I want to add dblOffset at that moment to dblReceive, which would then set dblReceive to zero.
Thanks.
|
|
|
|
|
I am having trouble figuring this out... even where to start. Basically I want to mimic the active directory browser. Listing all the OU's and their childs.
The hard part is I'm trying to do this backwards from what most people do I believe. What I have is a list of USERS and their DISTINGUISHEDNAME.
So:
I have a user:
CN=Jacob Dixon,OU=INFO TECH,OU=MAIN DIVISION,DC=company,DC=com
So what I did was:
string[] dn = usr.DistinguishedName.Split(',');
Array.Reverse(dn);
I then loop through each string ignoring EVERYTHING except for strings that start with "OU=". Anyone have an example on how to accomplish this?
I have tried something like this:
TreeNode root = new TreeNode();
TreeNode prev = new TreeNode();
foreach (string s in dn)
{
if (s.Contains("OU="))
{
string tmp = s.Replace("OU=", string.Empty);
if (string.IsNullOrEmpty(root.Text))
{
root.Text = tmp;
}
else
{
if (string.IsNullOrEmpty(prev.Text))
{
prev.Text = tmp;
root.Nodes.Add(prev);
}
else
{
TreeNode n = new TreeNode();
n.Text = tmp;
prev.Nodes.Add(n);
prev = n;
}
}
}
}
tvUsers.Nodes.Add(root);
It does the root and children but it also inserts duplicates.. (I know I'm not checking right now for duplicates). I'm just having a hard time figuring this out..
|
|
|
|
|
Hi,
In one of my tables I have a column with type char(1). When I used LINQ to SQL, this column was correctly mapped to "char" type but when using Entity Framework its being mapped to "String" type as opposed to "char".
Also there isn't seem to be an option in the Type drop down to select "char".
Can anyone shed some light on this matter?
|
|
|
|
|
I created a Windows Service that is installed on a server. Whenever any type of any error is thrown, the error is logged and the service stops.
Is there anyway to setup my try/catch to make sure the service continues to run after the error is logged?
static void Main(string[] args)
{
AppDomain currentDomain = AppDomain.CurrentDomain;
currentDomain.UnhandledException += new UnhandledExceptionEventHandler(currentDomain_UnhandledException);
#if !DEBUG
try
{
#endif
#if DEBUG
isDebugMode = true;
object debug = new object();
MessagingBroker(debug);
#else
ServiceBase.Run(new Program());
#endif
#if !DEBUG
}
catch (Exception e)
{
string msg = "Error: " + e.Source + "\r\n";
msg += "Message: " + e.Message + "\r\n";
msg += "Stack Trace: " + e.StackTrace;
sEvent = e.Source;
LogEvent(msg, EventLogEntryType.Error);
}
#endif
}
Thanks,
Joe Brislin
|
|
|
|
|
That doesn't look like a Windows Service to me.
|
|
|
|
|
It runs as a console application when in debug mode to help with programming and debugging but can also be installed as a Windows service.
|
|
|
|
|
Where is your OnStart method? That's the one you should protect with a try/catch block. Your Main() function is not on the stack when the SCM calls Onstart().
Oh and BTW, what is Program() ? It should be a ServiceBase (Hopefully with some initialization in the constructor) for this code to work.
Note that you don't have to override OnStart, but if you don't your service won't do anything (which is still the best way of not generating errors )
|
|
|
|
|
Michel Godfroid wrote: OnStart
OnStart isn't even the important method.
|
|
|
|
|
No, but it's a start
|
|
|
|
|
Michel,
Thanks for the reply. You get me headed in the right direction. I actually needed to have my try/catch in the Service Method that is called in the OnStart. Everything is working like a charm now. I appreciate the help.
Thanks,
Joe Brislin
|
|
|
|
|
Joe Brislin wrote: try/catch in the Service Method
Exactly. Very good.
|
|
|
|
|
Hey everybody, if somebody can help me with this I'd really appreciate it. I'm currently writing a Ticketmaster esque program, in which we have to have a user log-in and out of the program. Well I have a main form, and a log-in form. The user clicks a linked label on the main form to load up the log-in form. Sign in with their credentials and click the log-in button on the log-in form. I have it reading from and checking an access database file to make sure that they have log-in information and that it is correct. What I need now is to be able to pass the [username] from the database that they use on the login form back to the main form, so that the program can recognize if an administrator logs in. Here is my main form code for the log-in button:
private void lnklblLogIn_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
sp.Stop();
frmLogIn LogIn = new frmLogIn();
LogIn.Show();
}
and here is my log-in form code for the log-in button:
private void btnLogIn_Click(object sender, EventArgs e)
{
OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Users\\John\\Desktop\\Database1.mdb");
OleDbCommand com = new OleDbCommand("SELECT UserName, PassWord FROM Table1",con);
OleDbDataReader reader;
bool permit = false;
try
{
con.Open();
reader = com.ExecuteReader();
while (reader.Read())
{
if (txtUserName.Text == (reader["UserName"].ToString()) && mtxtPassWord.Text == reader["PassWord"].ToString())
{
permit = true;
break;
}
}
con.Close();
}
catch
{
MessageBox.Show("File not able to be read");
return;
}
if (permit != true)
MessageBox.Show("Username or Password are not correct.");
else
{
Close();
}
}
So again my issue is being able to get the username logged in with on the "Log-in" form back to the main form so the main form knows who has logged in. If somebody can help me with this I'd really appreciate it
|
|
|
|
|
why not just add an event to the login form. Call it something like "UserLoggedInSuccessfully".
public class MyEventArgs: EventArgs
{
private string _UserName;
public MyEventArgs(string UserName)
{
_UserName = UserName;
}
public string UserName()
{
return _UserName;
}
}
public delegate void myEventHandler(object sender, MyEventArgs e)
public class LoginForm: Form
{
public Event myEventHandler LoginSuccessful;
...
}
Then, when the login is successful you call:
LoginSuccessful(this, new MyEventArgs(UserName));
and hook it on the main form. When the event is raised on the main form, you can check the username to see who it is.
|
|
|
|
|
For this, the best method is probably to set up a public property (called say UserName) in the log in form and then change your main form code to:
private void lnklblLogIn_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
sp.Stop();
myUserName = "";
frmLogIn LogIn = new frmLogIn();
if (LogIn.ShowDialog() == DialogResult.OK)
{
myUserName = LogIn.UserName;
}
} You may want to take some action (like closedown) if the dialog result is not OK
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
I'm having trouble getting the main form to recognize LogIn.UserName, what could I be missing? I tried making the oleDb stuff public but that won't work.
|
|
|
|
|
OriginalGriff wrote: set up a public property (called say UserName) in the log in form
Or did you miss that bit?
for example:
private string userName;
public string UserName
{
get { return userName; }
} Declares a read-only string called UserName that can be accessed outside the login form.
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
Thank you very much, yeah forgot about that part lol. I was trying to pass the reader and reread from the DB again I guess lol. This makes it a lot eaiser and pushed my project ahead a lot lol. That was the one speed bump I couldn't get over. Thank you again.
|
|
|
|
|
Hi
Im developing a windows CE app. I have inherited user controls which i use as screens which i can switch between. All working fine. One thing i'd like to do is set the system clock on the CE device. To do this i need to do [DllImport("coredll.dll")]. When i do this i can no longer get access to the designer screen and get the following messgae
<html><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"><title></title><style>.ErrorStyle { font-family: tahoma; font-size: 11 pt; text-align: left}.DetailsStyle { font-family: tahoma; font-size: 10pt; text-align: left;text-indent: 0; word-spacing: 0; line-height: 100%; float: left; margin-top: 0; margin-bottom: 0}.StackStyleVisible { font-family: tahoma; font-size: 10pt; text-align: left; margin-left: 20; text-indent: 0}.StackStyleHidden { display:none; font-family: tahoma; font-size: 10pt; text-align: left; margin-left: 20; text-indent: 0}</style></head><body><DIV class="DetailsStyle" width="100%"><table border="0" width="100%" id="table1" height="100%" cellspacing="0" cellpadding="0"><tr><td height="40" bgcolor="#FF9999" width="8%" style="letter-spacing: 0" align="center"><img border="0" src="C:\Documents and Settings\Chris Clarke.PIPECOIL\Local Settings\Temp\13113A5.tmp" width="35" height="35" alt="ErrorImage" ></td><td height="40" bgcolor="#FF9999" width="91%" style="vertical-align: top; letter-spacing: 0" align="left"><b><font size="2" face="Arial" fontsize="70%">One or more errors encountered while loading the designer. The errors are listed below. Some errors can be fixed by rebuilding your project, while others may require code changes.</font><font size="2" face="Arial"></font></b></td></tr><tr><td colspan="2" align="left" valign="top"><DIV id="div1" class="ErrorStyle" width="100%"><span style="font-weight: 600"><br>The type 'Microsoft.CompactFramework.Design.UnsafeUserControl' has no property named 'Colour'. </span><br><a href="" id="details0">Hide</a><font color="#0000FF">  </font><a href="" id="task0">Edit</a><font color="#0000FF"></font></span></DIV> </td> </tr> <tr><td colspan="2" align="left" valign="top"><DIV id="div20" class="StackStyleVisible" width="100%"><br> at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.Error(IDesignerSerializationManager manager, String exceptionText, String helpLink)<br> at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializePropertyAssignStatement(IDesignerSerializationManager manager, CodeAssignStatement statement, CodePropertyReferenceExpression propertyReferenceEx, Boolean reportError)<br> at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeAssignStatement(IDesignerSerializationManager manager, CodeAssignStatement statement)<br> at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager manager, CodeStatement statement)</DIV></td></tr></table></div></body></html>
When i run the project on the device it works fine. all the screens work and i can even set the time.
Anybody got any ideas about this error? been pulling my hair out for a bit now.
Thanks
Chris
Chris
|
|
|
|
|
Are you compiling with the /unsafe target?
|
|
|
|
|
kevinnicol
I'm compiling it to a windows CE device. but even in visula studio the user controls are not visible
Chris
|
|
|
|
|
Hi all,
I've been looking for a way to write data to a CSV file based on a timer event, without success. Is there a standard .NET class that will do this?
Thanks.
|
|
|
|
|
There are timer classes and there are classes to perform file I/O. Were you expecting specialized support beyond this? If so, what kind?
/ravi
|
|
|
|
|
What I would like to do is write a variable value to a csv file dynamically at a certain interval (timer tick). Each tick would result in a new line in the csv file.
|
|
|
|