|
I have a form and I want to do something if the user presses F2. I have tried using the on key press, but the user will be entering info in text boxes and so it does not fire that form event.
And even better if there was a way to make it so if the user pressed F2 anywhere in the app it would fire a bit of code.
Any ideas?
TIA
-- modified at 5:06 Wednesday 2nd May, 2007
|
|
|
|
|
By setting the Form.KeyPreview property to true, your form gets informed about keyboard events before they are passed to the control that has focus.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
|
Hello Stefan, you seem to know much about keys .. do you know how to capture key strokes without activating my form.. that is, on windows desktop or another windows, like when you want one key to function the same way "ie. launching an application" when pressed anywhere, anytime.. Thank you Stef
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
In that case you need to use hooks
|
|
|
|
|
Search the article for "hooks".
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
hooks thanx!
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
hi...
how to display a solid square composed of a character input.
for example:
square size = 4
fill character = #
result:
####
####
####
####
|
|
|
|
|
use 2 for loops ... simple program..
Vikram
I Code...
|
|
|
|
|
It can be done in one loop, if you use new string('#', squareSize) to output a row.
|
|
|
|
|
ya. use a couple of loops. something like this. since you have asked for 4 hashes on 4 lines, use something like this.
for(int i = 0; i < 4; i++)
{
for(int j = 0; j < 4; j++)
{
Console.Write("#");
}
Console.WriteLine();
}
Keshav Kamat
India
|
|
|
|
|
yes. it can be done using a single loop as well
Keshav Kamat
India
|
|
|
|
|
Wow. Nothing like doing his homework for him! Great! Now he didn't learn a thing and will fail on the next project.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
This is obvioulsy homework, I am sorry that someone did it for you. It won't help you learn. Now that you have the code, look at it, think about how it works, and what you were supposed to learn from writing it yourself.
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 )
|
|
|
|
|
OK - you've posted the same question twice now. You should reply/add clarifications on the one below, plus you really shouldn't try to get us to do your homework for you. That's just lazy, and you will come away with the only lesson learned being that we know more about programming than you do.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Yet another homework poster
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
I have a class for some stuff and i want to make a new object every time i get an indication of a new node.
I would like to make the name of the objects dynamical, i.e.
Node NewNode = new Node();
I would like the NewNode to have a number after it, so I tried:
Node "NewNode"+Number = new Node(); but this won't work
Does anyone know how i can do it??? Rather not with arrays because then i'll have to predefine how big my array has to be, and I don't know that.
Thanks
|
|
|
|
|
You're much better off using a collection for this. Why not look at a generic List ? Then you would get the following code (as an example):
private List<Node> _nodes = new List<Node>();
public void AddNode(Node node)
{
if (node != null)
{
_nodes.Add(node);
}
}
public void AddNode(Node[] nodes)
{
if (nodes != null && nodes.Length > 0)
{
_nodes.AddRange(nodes);
}
}
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
List<Node> nodeCollection = new List<Node>();
...
Node newNode = new Node();
.. set unique values
.. use in unique processes
nodeCollection.Add( newNode );
This will let you have a group of objects with an unknown number created without concern for the name of the object.
|
|
|
|
|
Hi! newbie here just asking which of the following code is more efficient
1.
DataRow[] dataRowArray = dtDataTable.Select("TableColumn = 1");
foreach(DataRow drRow in dataRowArray)
{
...some processing here
}
OR
2.
foreach(DataRow drRow in dtDataTable.Select("TableColumn = 1"))
{
...some processing here
}
my problem here is do I need to put the result in a datarow array to make it more efficient? or not an issue at all?
|
|
|
|
|
Both the statement will give same efficiency.
If you have a scenario where you want the result object of dtDataTable.Select("TableColumn = 1") , then go for the first statement.
otherwise go for the second.
|
|
|
|
|
Hi Friends,
Please help me for the below requirement.
Note:
Typed Datasets are considered for the requirement.
Here, LookupTableDataSet Typed Dataset consists of the Agency and Authority DataTables.
I have two methods as given below.
public Int32 GetRowsInTable(String tableName)<br />
{<br />
Int32 result = 0;<br />
<br />
LookupTableDataSet ds = new LookupTableDataSet();<br />
<br />
System.Data.DataTable dataTable = Fill(ds.Tables[tableName]);<br />
result = dataTable.Rows.Count;<br />
<br />
return result;<br />
}<br />
<br />
<br />
public LookupTableDataSet.AgencyDataTable Fill(LookupTableDataSet.AgencyDataTable dtAgency)<br />
{<br />
AgencyTableAdapter adapter = new AgencyTableAdapter();<br />
adapter.Fill(dtAgency);<br />
return dtAgency;<br />
}<br />
<br />
public LookupTableDataSet.AuthorityDataTable Fill(LookupTableDataSet.AuthorityDataTable dtAuthority)<br />
{<br />
AuthorityTableAdapter adapter = new AuthorityTableAdapter();<br />
adapter.Fill(dtAuthority);<br />
return dtAuthority;<br />
}
1. GetRowsInTable(String tableName) should return the row count for the table name sent as the parameter.
2. Fill() method is overloaded with different types of input parameters and return types.
My requirement is that I have to pass the table name as the parameter to the GetRowsInTable() method to get the rows count for the table.
As the Fill() method is overloaded with different types of input parameters how can I convert the input parameter to a specific type based on
the tablename which was sent as a parameter to the GetRowsInTable() method?
When I call the fill method as Fill(ds.Tables[tableName]), A System.Data.Dataset is being passed to the Fill() method where the fill method will accept only types
LookupTableDataSet.AgencyDataTable or LookupTableDataSet.AuthorityDataTable.
How can I dynamically convert the System.Data.DataSet to the required type to call the Fill() method.
Also, please suggest me on dynamically casting the return types of Fill() methods.
Statement throwing compilation errors were shown in Bold+Italic.
Thanks in advance.
Subrahmanyam K
|
|
|
|
|
It looks like your method has custom types in it, I've nevr heard of an AuthorityDataTable before.
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 )
|
|
|
|
|
Yes, you are right. I have custom types.
LookupDataSet is a Typed Dataset and AuthorityDataTable is a Typed DataTable in that dataset which maps to the Authority database table at the back-end.
Subrahmanyam K
|
|
|
|
|
Hi,
Im creating a new user account in the windows account here the username=tricomp and password=tricomp and the domain name=TRICOMPTECH
Actually whats my query is,im using C# Windows.Net 2003 here in the form in textbox1 im entering the username as "tricomp" and in textbox2 im entering password as "tricomp" and im passing the domain name as "TRICOMPTECH"..Now while onclicking the ok Button if i entered the correct username and password means i need messagebox.show("validuser") else messagebox.show("Invaiduser").and also specify what are all the namespace i have to refer...How do i accomplish this..since im trying this process for last one week but im couldn't get the clear solution..Plz help me..
regards
Kanna...
|
|
|
|