|
When the form loads, have it make itself invisible, and then show the login form. If login fails, close. If it succeeds, show the main form.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
I did it. in main form I write this code in from.load event :
this.Hide();
Frm_LogIn_User frm = new Frm_LogIn_User();
frm.ShowDialog(this);
this code correctly work but in the login form in button1.click enevt I write this code :
if (textBox1.Text == "1" && textBox2.Text == "1")
{
Frm_LogIn_User frm = new Frm_LogIn_User();
frm.Dispose(this);
}
this code does not work and I think maybe the code is wrong.
I would appreciate of somebody help me.
thanks
|
|
|
|
|
Alireza3839 wrote: textBox1
Why don't your controls have real names ?
Alireza3839 wrote: Frm_LogIn_User frm = new Frm_LogIn_User();
frm.Dispose(this);
What is this for ? What are you trying to achieve ?
Set a public boolean property on your login form called something like LoginSucceeded.
Then do this:
frm.ShowDialog(this);
if (frm.LoginSucceeded)
{
this.Visible = true;
}
else
{
this.Close();
}
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hey everyone,
I have a ASP.NET C# website. On one of my pages I have a datagrid and when the user clicks on the surname it has to pass two values. One is the student ID and the other is the TB_ID. I made the student ID the ItemIndex field so that was easy to get when you click on a student. But I cannot get the TB_ID value from the grid when you click on the surname. This is the code so far:
// find student id and training block for selected record
stPersId = dgGrpReport.DataKeys[e.Item.ItemIndex].ToString();
//TBID = dgGrpReport.Columns(rows[1]).ToString();
//TBID = ((Label)dgGrpReport.SelectedItem.Cells[1].FindControl("TB_ID")).Text;
//TBID = e.Item.ItemIndex[1].ToString();
//TBID = dgGrpReport.SelectedItem.Cells(1).Text;
Response.Write(TBID + " - " + stPersId);
As you can see I've tried a few combinations. Any ideas?
Thanks of course in advance, I appreciate the help!
Michael
|
|
|
|
|
Hello,
I'm trying to highlight selected text in a RichTextBox Control.
I want to do this by using the RTF control code \cbn where n = index.
As I understand you prefix the selected text with a \cbn code to change the background color to the highlight color then Postfix it with another \cbn code to reset color back.
See COMMENT BELOW for full description
//RTF Color codes with indices into Color Table
private const string clrDefault = @"\cf1 ";
private const string clrKeyword = @"\cf2 ";
private const string clrLiteral = @"\cf3 ";
private const string clrOutlining = @"\cf4 ";
private const string clrComment = @"\cf5 ";
private const string clrSelect = @"\cf6 ";
//The actual individual entries in the Coor Table
protected static string colorDefault = @"\red0\green0\blue0;";
protected static string colorKeyword = @"\red15\green0\blue255;";
protected static string colorLiteral = @"\red200\green105\blue36;";
protected static string colorOutlining = @"\red27\green175\blue78;";
protected static string colorComment = @"\red160\green160\blue160;";
protected static string colorSelect = @"\red90\green90\blue90;";
//Code to build the Color Table string
protected static string rtfColorTable = @"{\colortbl ;" +
colorDefault +
colorKeyword +
colorLiteral +
colorOutlining +
colorComment +
colorSelect +
@"}";
public static void HighlightSelection(RichTextBox rtb, string selTxt)
{
string result = rtb.Rtf;
//Replaces existing colorTable with mine
result = CreateColorTable(result);
Regex r = new Regex(selTxt);
// COMMENT BELOW
//If I use clrSelect + selText + clrDefault
// i.e. @"\cf6 " + selText + @"\cf1 "
//The proper keywords foreColor changes to gray.
//But when I use the \cbn equiv. it doesn't??
result = r.Replace(
result,
@"\cb6 " + selTxt + @"\cb1 ");
rtb.Rtf = result;
}
Thanks for your time!
Mike
P.S. Does anyone know a good Regex reference?
Light travels faster than sound. That's why some people appear right until you hear them speak.
|
|
|
|
|
http://www.ultrapico.com/Expresso.htm
Download the tool , its a tool to test regular expression and with few example of regex
|
|
|
|
|
Thanks for the link...Expresso is much better than the one I was using.
Thanks
Mike
Light travels faster than sound. That's why some people appear right until you hear them speak.
|
|
|
|
|
we have a project got some button,if we run the step by step demo function,our teacher ask us after click the first button,the second button which should click will be highlight.So user can follow the highlight button to run the project.Do not know how to highlight the button,any ppl can give a idea?thanks a lot!waiting for your reply!
|
|
|
|
|
Not sure what you mean by highlight, but you can change the background color to make it more conspicuous. Something like this in button1's Click event handler:
button2.BackColor = Color.AntiqueWhite;
Cheers,
Vıkram.
Déjà moo - The feeling that you've seen this bull before.
Join the CP group at NationStates. Password: byalmightybob
|
|
|
|
|
You can make the button BOLD and/or the font size as required:
cmdTest.Font.Bold = true;<br />
cmdTest.Font.Size = 18;
If that is what you require...
|
|
|
|
|
I guess what you want to do is
nextButton.Focus(); //this will highlight(input focus) the nextButton
|
|
|
|
|
Hi all,
I'm coding a small math library for an app we are developing. Its basically 3D math, Vectors, Matrix, etc.
I'm currently coding a struct Vector3D and I've overriden Equals(obj b) and was currently studying if I needed to override GetHashCode() or if the base implementation would work. A few simple tests proved that the default base implementation will not work as I'm getting same HashCodes for different Vectors and that's not good :p.
I'm not even sure I really need to implement a safe HashCode algorithm because I don't foresee the vector struct being used in such scenario, but still, I wouldn't like to leave something in my code that I know is not right. Never know how someone might consume the library in the future.
So my question is: Can somebody point me out how I should go about generating a unique int from 3 random doubles? My vector has obviously 3 coords, xyz and two vectors are the same only if all coords are the same which means that my GetHashCode() should generate a unique number for each combination of (x,y,z).
Any suggestions are welcome.
P.D. I'm not even sure if its possible to do. If I stop to think about it, you have a finite set of hashcodes you can generate (int.Min,int.Max) while the combination of diferent x,y,z coords is endless. Am I misunderstanding the point of GetHashCode()?
-- modified at 19:13 Wednesday 9th May, 2007
|
|
|
|
|
Hi,
AFAIK has codes dont have to be unique (and as you pointed out, they
typically cant).
The one requirement is that the same object must return the same hash code
over and over. Basically it must always be true that
hash(obj1) != hash(obj2) ==> obj1 != obj2
You could satisfy this by having a constant hash (the hash based mechanism
does not provide any benefit then), or by having the hash equal to (or derived
from) just a few of the object's data bytes.
Of course if you expect to rely on effective hashing, then the hash values
should have a good distribution. So it is up to you to determine the balance
between costs and benefits.
|
|
|
|
|
Hi Luc, thanks for the reply.
I'm still missing something or I am completely confused and mistaken with the whole concept. Bear me out please:
The requirement of a hash code you are saying is:
if ob1 != obj2 ==> hash(obj1) != hash(obj2)
Ok I understand that, but it also has to comply with:
if obj1 == obj2 ==> hash(obj1) == hash(obj2)
I really dont see how you can manage this with a simple algorithm when it comes to Value types.
If we are talking about objects where reference equality is acceptable, then yes, it doesn't have to be unique with all possible cases, only with the existing object instances in memory...an easy hash that comes to mind in that case is returning the memoryaddress of the object (this will ensure the uniqueness of the hash and ensures that no other object can have the same hash while its in scope).
But with value types (and some reference values too I guess (string comes to mind)) this behaviour of the Hash algorithm isn't acceptable. For example, take this code:
public void Example(Vector v1)
{
bool same = areSame(v1, v1);
}
public bool whatEver(object o1, object o2)
{
return o1.GetHashCode()==o2.GetHashCode();
}
this code will return false if we implement a reference equality hash code which doesnt make sense, as its the same vector even if its boxed in two different memory addresses.
But how do we code a HashCode that will return you the same int for o1 and o2 but can assure you that no other existing vector in memory gives you that same code unless its also the exact same vector?
Obviously its impossible to get an algorithm that can give you a unique int for all possible existing vectors (we dont have enough ints to do that) so the solution must be to ensure that the hash works as expected with the existing set of vectors in memory.
Again, am I misunderstanding the meaning of GetHashCode() completely?
-- modified at 4:47 Thursday 10th May, 2007
|
|
|
|
|
Hi,
Sorry, my original reply was wrong. Of course there is only one requirement:
if obj1 == obj2 ==> hash(obj1) == hash(obj2)
The inverse is not necessary (and cannot be achieved in general, since one
cannot perform lossless compression from some amount of data towards a single
32-bit int).
I think the "remarks" in MSDN on Object.GetHashCode are clear.
It states:
"For best results, the hash code must be based on the value of an instance field or property"
and
"GetHashCode must always return the same value for a given instance of the object"
Now value types that get boxed twice produce two different objects,
their Hash Code does not have to be identical.
BTW I dont consider a Vector a value type.
Hope this helps.
|
|
|
|
|
Ok, thanks again for the reply.
I think I understand now. Anyhow, if you take a look at how MS generates hashcodes of ValueTypes like System.Drawing.Point you will notice that the same point boxed twice does produce the same hashcode even if they are not the same object, so I'd like to take that same approach. Does not seem that complicated anymore if we don't have to ensure uniqueness.
Just out of curiosity why wouldn't you implement a 3D vector as a value type as similar structs like System.Drawing.Point is? Am I missing some major drawbacks?
P.D. About MS comments on how GetHashCode() should behave I understand it perfectly but MS has one more recommendation and its that GetHashCode() should be compatible with .Equals(object o). Thats why the compiler flags you a warning that you should consider overriding GetHashCode() when you override .Equals(object o) (very normal situation when coding structs). That's what got me stumped as it's simply not possible to achieve 100% compatibility.
-- modified at 5:12 Thursday 10th May, 2007
|
|
|
|
|
Hi,
I was thinking of a Vector as it exists in Java (it is similar to C#'s ArrayList).
If your Vector is just a fixed and small number of coordinates, of course it
can be a value type.
|
|
|
|
|
hi all,
i want to detect all the pdf files link which are downloadable on webpage,
i need regular expression for that so that i can detect all the links.
can any one here to help me in that issue, i shall be thankful to my friend.
Regards,
Neo
|
|
|
|
|
Can't you just search for
[^\"\<\>\|\x0000\x0001\x0002\x0003\x0004\x0005\x0006\a\b\t\n\v\f\r\x000e\x000f\x0010\x0011\x0012\x0013\x0014\x0015\x0016\x0017\x0018\x0019\x001a\x001b\x001c\x001d\x001e\x001f\:\*\?\\\/]+\.pdf Basically what I've done here is used Reflector to look for all characters which .NET believes are invalid filename characters (the bit inside the [^...] + , the regex then looks for a group of one or more of these characters followed by a .pdf (\.pdf ).
Have not tested it and do not accept resposability
|
|
|
|
|
Thanks , But I am using Sockets and dont want to use Remoting.
So what If I put my assembly in GAC and App A and App B access it from there ? would not it be shared among these 2 applications ? and If I put singlton patteren on Class X to create only object then shoudl't App A and App B get same object ?
OR even if u put assembly in GAC , everny App creates its own instance of assembly ?
Thanks
|
|
|
|
|
Hi ,
I have question about .NET assemblies , say I have a Assembly 'X' and that conatins class 'xx' and my two different seperate applications uses this assembly , say Appl'A' and App'B' .
Then is it possible that I could share the object of class 'xx' in two applications ?
Like App'A' initiate object of class 'xx' and later on when App'B' comes, somehow I could tell that application that object of class 'xx' is already created and use that same object which App'A' has created.
Is it possible to do ?
I will really apprecaite if you could help me out here
Thanks,
ZINK
ZINK
|
|
|
|
|
You can accomplish this using .NET remoting: if AppA created the object, it would publish the object using .NET remoting's RemotingServices.Marshal(...) method. Then, AppB can connect to this same object using RemotingServices.Connect(...) .
|
|
|
|
|
I have developed a glossary application whereby users can insert terms into the glossary. I have a function to check for duplicate word entries. Unfortunately there is a minor flaw here in the fact that a user can enter the same word with a leading space and it will be entered in the db as a new word. I.E. The Word and The Word[space] are to different entries. Is there a way to delete leading white spaces after/before a character string. Also I do not wish to delete words with spaces in between the words (i.e. The[space]Word). All suggestions welcome and future thanks to all that reply.
|
|
|
|
|
Have a look at Trim function an d its overloads of string class
|
|
|
|
|
Use the Trim() method of the string object, e.g.:
string textToEnter = " Citizen Kane";
textToEnter = textToEnter.Trim(); // it is now "Citizen Kane"
|
|
|
|