|
In obj2.show you can move form everywhere but in another case it can move in the parent form area. I guess.. 
|
|
|
|
|
freshonlineMax wrote: n obj2.show you can move form everywhere but in another case it can move in the parent form area. I guess..
You guess wrong.
The second example just shows a dialog box. There's no constraint in where it can be moved - the constraint is in how you can interact with the hosting application. As it's modal, processing on the primary thread halts in the calling code until it is dismissed.
|
|
|
|
|
As an addition to what others have told you, the Form object must be disposed later if you show it with ShowDialog method, so in this case it is much better to do this:
using (Form2 obj2 = new Form2())
{
obj2.ShowDialog();
}
|
|
|
|
|
An additional addition to the previous good answers...
ShowDialog returns a value of type DialogResult that enables you to determine the result of whatever that form was shown for - useful for custom message box type dialogs etc.
|
|
|
|
|
Yes Both are using for showing Form.
But Firt one is used for showing form as a normal form.
But Second One Is Used for Showing Form as a Dialog. You can not access Normally from Mouse or Keyboard.
First Case shows Non Immediate Value Required.
Second Shows Must Value Required.
Best Regard
If you can think then I Can.
|
|
|
|
|
Hi,
I've tab control in my application and the shape looks like below.
_____________
tab1 |tab2 |
-----------------------------------------------
|
|
|
|
-----------------------------------------------
tab headers are in rectangle shape
But I would like design the tabs as below (as we have in visual studio)
_____ ______
/tab1 |/tab2 |
-----------------------------------------------
|
|
|
|
----------------------------------------------- Please guide me to change the shape of tab header
|
|
|
|
|
|
|
you're welcome.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Hello Everyone
I have created a Client/Server application on C# on WPF IDE and I have a little problem on my UserClient property class...
Within this class I have a method called:
public override bool Equals(object obj)
{
UserClient temp = obj as UserClient;
if (temp != null)
{
return (userId == temp.userId);
}
if (temp != null)
{
return (userPass == temp.userPass);
}
return false;
}
The problem I'm having is:
The class UserClient is highlighted with a green line under-neath where when I place MouseOver it sas:
UserClient overrides Object.Equals but does not override Object.GetHashCode
Here is the entire UserClient class code:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
namespace DtposClient
{
public class UserClient
{
private string UserFullName;
private string UserAccessLevel;
private int UserId;
private int UserPassword;
public string fullName
{
get { return UserFullName; }
set { UserFullName = value; }
}
public string accLevel
{
get { return UserAccessLevel; }
set { UserAccessLevel = value; }
}
public int userId
{
get { return UserId; }
set { UserId = value; }
}
public int userPass
{
get { return UserPassword; }
set { UserPassword = value; }
}
public override bool Equals(object obj)
{
UserClient temp = obj as UserClient;
if (temp != null)
{
return (userId == temp.userId);
}
if (temp != null)
{
return (userPass == temp.userPass);
}
return false;
}
public UserClient(string fullNam, string aLevel, int usId, int pass)
{
fullName = fullNam;
accLevel = aLevel;
userId = usId;
userPass = pass;
}
}
}
Could someone please help me crack this problem....
thanks in advance
kind regards
lapeci
|
|
|
|
|
It's a warning that you are not implementing best practices. You can read the rule description here to understand why
"You get that on the big jobs."
|
|
|
|
|
Moreover, this code fragment :
if (temp != null)
{
return (userPass == temp.userPass);
}
will never be executed (if temp != null, the method will still have returned a value).
The error you get is because when you override the Equals() method, compiler is expecting you also override the GetHashCode() one :
public override int GetHashCode()
{
return UserId;
}
You can also have a more complex hashcode generation, for example :
public override int GetHashCode()
{
return UserId ^ UserPassword ^ UserFullName.GetHashCode() ^ UserAccessLevel.GetHashCode();
}
Here it's up to you to decide which elements of your class will be taken for the hashcode generation.
|
|
|
|
|
Let me help you with this method:
public override bool Equals(object obj)
{
UserClient temp = obj as UserClient;
return temp != null && userId == temp.userId && userPass == temp.userPass;
}
I guess this is what you wanted it to do. For the warning you mention, I think someone has already told you to make a customized GetHashCode for your UserClient class.
|
|
|
|
|
Hello,
I have created a Process that runs a command from cmd and handles it's output using event Handler.
I want to input user name when cmd asks for "Enter Username :". This comes immediately after 1st line. Then comes Enter Password where I want to pass password. Then their is no input and can use my event handler till I am done.
I tried the following, but didn't work :
processInfo = new ProcessStartInfo("cmd.exe", "/C " + command);
sb = new StringBuilder();
processInfo.UseShellExecute = false;
processInfo.RedirectStandardOutput = true;
processInfo.CreateNoWindow = true;
public int ConnectToServer()
{
processInfo.RedirectStandardInput = true;
process = Process.Start(processInfo);
process.StandardInput.WriteLine("username");
process.StandardInput.Flush();
process.StandardInput.WriteLine("myPswd$");
process.StandardInput.Flush();
process.StandardInput.Close();
process.BeginOutputReadLine();
process.OutputDataReceived += new DataReceivedEventHandler(Process_OutputDataReceived);
}
private void Process_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
string d = e.Data;
if (!string.IsNullOrEmpty(d))
{
if (d.indexOf("Completed")) {
connected = true;
}
}
}
It shows error authentication failed. I guess I didn't input username & passowrd on time, so this must have happened. How to know when the app is asking to write and to write proepr details ? I didn't find such way of inputting in any articles searched on internet.
Any help is highly appreciated.
Thanks & Regards,
|
|
|
|
|
how about adding username and password as command arguments
eg.
cmd.exe "username" "password"
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Thanks Dear,
But no, can't add like that. Can either pass a txt file or input on screen. As I don't want to have txt file with readable username & password, so thought of this option.
Thanks & Regards,
|
|
|
|
|
Perhaps you're looking for this[^]?
|
|
|
|
|
Thanks, but I don't want such huge code for a small task.
I believe such a thing can be done with no big pain. Couple of days ago I had seen a codeo nsome site that showed stdin & stdout using Process and cmd. I searched a lot but couldn't find that site back.
On my start of process, immediately after 1 line, cmd needs to input username. The code I have written doesn't let the user write anything and just goes away. When and how can the app know that it needs to write/input something. If its the 1st time then its username, if 2nd time then password. That's it. Then no input only get the output.
But am not able to know when and how to know. Just saw WaitForInputIdle(). Might be that can help me. Will try with that.
Thanks & Regards,
|
|
|
|
|
I think you don't need anything going asynchronous here. Remove the OutputDataReceived event handler and the invoke to BeginOutputReadLine, so you can do it synchronously. For example:
I've not tested the code, but I guess it should work. The OutputDataReceived is only fired when a line is written on the output stream, so if there is not an end of line when it is asking for a username, you will not receive the event.
|
|
|
|
|
Why stack trace is not preserved in that code?
static void Function()
{
try
{
int[] data = new int[10];
data[100] = 1;
}
catch (Exception e)
{
throw;
}
}
static void Main(string[] args)
{
try
{
Function();
}
catch (Exception e)
{
Console.WriteLine(e.StackTrace);
}
}
The results are the same for throw or throw ex .
at ExTest.Program.Function() in ... ExTest\Program.cs:line 21
at ExTest.Program.Main(String[] args) in ... ExTest\Program.cs:line 29
Чесноков
|
|
|
|
|
You need to throw a new exception to preserve Inner Exceptions:
Try This:
try
{
Function();
}
catch(Exception ex)
{
throw new Exception("Your new error message", ex);
}
Hope this helps.
|
|
|
|
|
Documentation states that throw preserves stack trace and throw e does not.
You approach incurs handling of the inner exceptions.
Чесноков
|
|
|
|
|
Chesnokov Yuriy wrote: throw e does not
incorrect.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Dear All,
I have a query in teechart.
I have created a horizontal bar chart in C# using tee chart. Now i want to change the color of the bar depending on its value(e.g. green color for positive value & red for negative).
any settings in the property?
can anyone give solution on this?
thnx
|
|
|
|
|
Hello all,
Many times during working on web projects I come across handling the customized search page for comodity. Many times it contains 10 to 20 fields which is quite a good number to pass another page and to code.
I want to know if there is any efficient way to handle such situations.
Thanks
|
|
|
|