|
Why do you need to create button array? I don't know what are you working on, but array of buttons can be initialized as well as any other array:
Button[,] abtn;
of if you want jagged array, use:
Button[][] abtn;
Then traverse all buttons using for cycle and set their properties:
Button btn = Button[3, 2];
btn.Size = btnSize;
btn.Parent = this;
...
|
|
|
|
|
actually i have already create an array like but it does'nt work for its properties.
ok let me explain actually i want 64 button. and i get user input not through button through textbox. input is obviously string and every input word has specific meanging like if input is C1 its means 3rd button.
initially there is some specific text on16 button from start and 16 button from the end.
if user give 3rd button for source and 7th button for destination then text displayed on the source button is replaced to des button and source button will become blank. can u tell me how i will handle it.
|
|
|
|
|
input is obviously string and every input word has specific meanging like if input is C1 its means 3rd button
Then why not use a hashtable, with string keys and button values?
using System.Collections;
...
Hashtable table = new Hashtable();
table.Add("C1", buttons[2]);
table.Add("C2", buttons[14]);
... and so on
Then when you need to access a button based off textbox input, go
string userEnteredString = "C1";
Button button = (Button) table[userEnteredString];
Is this what you're looking for?
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Homosexuality in Christianity
Judah Himango
|
|
|
|
|
ok this works. but what i want it is not working for it.
please help me .
i am explaing my problem in detail. first of all i want 64 buttons (like 8 rows and 8 columns )on my from.and i have to textbox one is for source and one for destination input.user is restricted that he gave input like a1,b1,c1,d1,............a8,b8,d8.after getting source and destination input i want to set if user gave in source tetxbox c1 its means source is 2 like this for destination.and i know these are also source and destination button numbers.
then i want to pass this inputs to a function. after some validation when function returns that source and destination is valid i want to replace source button text to destination button text. and source button text become null.how i will find out that which button tag value is equal to source also for destination and then on this basis i will change it.
please tell.......soonnnnnnnnnn
|
|
|
|
|
We can definately create button array.
Button []btnArr = new Button[5];
for(int i = 0; i < 5; i++)
{
btnArr[i] = new Button();
btnArr[i].Text = "TestButton";
btnArr[i].Visible = true;
btnArr[i].Width = 50;
btnArr[i].Height = 20;
this.Controls.Add(btnArr[i]);
}
Give location also and it will work.
Jayant D. Kulkarni
Brainbench Certified Software Engineer in C#, ASP.NET, .NET Framework and ADO.NET
|
|
|
|
|
Hi,
Normally the view GUI is driven by user input event,
(i.e. when user click a button, the UI change). But
how to update the view if the model is changed(i.e. model-driven UI). What is the pattern for this kind of view update ? And for my program design, the model-driven update seems need to update the view in another thread from the user input event thread, will this make the View not stable or having conflict ?
Thanks
|
|
|
|
|
There won't be any conflict if you won't use same data in more threads without any control. I'm doing this job declaring event handler in the class (e.g. Form) which has to be updated on background. But the form checks if it is updating now and if yes, updating process begins again:
<br />
public void Update(object obj, EventArgs ea) {<br />
<br />
if (updatingThread.IsAlive)<br />
<br />
<br />
updatingThread.Start();<br />
}<br />
|
|
|
|
|
Alright,
I ask for collective advice. We have some developers at my company who enjoy embedding their unit tests within the actual class that they're testing, (so they can test private methods), while others prefer duplicate test classes outside of each individual class. I was curious as to what the forum has to say about unit test class location.
Thanks for the suggestions,
Ryan
|
|
|
|
|
The location is http://sourceforge.net.
Search for the below tools,
NUnit can be used for class library testing. For GUI testing you can use NUnitForm.
Live Life King Size
Alomgir Miah
|
|
|
|
|
For testing private methods/properties, I'd use methods internal to the class and put them in conditionally compiled blocks. I don't like the idea of duplicating all the code in other files, because then you're never really sure you're testin the real thing.
In fact, here's another trick: rather than having any test code at all in the classes under test, just add conditionally compiled public hook methods for the private methods and write all the unit test code externally (using NUnit, most likely). The unit test code can test the private methods by using the public test methods, which would just have the same signature, but include "_Test" (or something like that) in the name.
Matt Gerrans
|
|
|
|
|
Hi,
I have developed a system which copies the files from the remote servers and put it on the local server for further process on the files.
I have around lots of remote servers shared for that and having good amount of files everyday.
My system is a single thread system and goes to each server line by line, The issue is some time it gets hanged while coping the files from one of the server because of many reasons of network and does not go ahead for the other remaning server.
I am using C# and normal file.Copy method to do that.
Please tell me what is the best method of doing it and making system more better.
Thanks.
Nitin
|
|
|
|
|
How to call a stored procedure from sybase in .net(c#)?
I am using a OleDB connectionstring to connect to sybase database, but I don't know how to call a stored procedure to execute. Can anyone help, please?
|
|
|
|
|
hi,
i have some problems using the functions
LsaEnumerateLogonSessions
LsaGetLogonSessionData.
is there a simple sample for using this functions.
maybe the problem is my structure (forgive me the vb-code)?
<structlayout(layoutkind.sequential, charset:="CharSet.Auto)"> _
Private Structure SECURITY_LOGON_SESSION_DATA
Dim Size As UInt64
Dim LogonId As LUID
Dim UserName As LSA_UNICODE_STRING
Dim LogonDomain As LSA_UNICODE_STRING
Dim AuthenticationPackage As LSA_UNICODE_STRING
Dim LogonType As UInt64
Dim Session As UInt64
Dim Sid As IntPtr
Dim LogonTime As Int64
Dim LogonServer As LSA_UNICODE_STRING
Dim DnsDomainName As LSA_UNICODE_STRING
Dim Upn As LSA_UNICODE_STRING
End Structure
many thanks in advance.
regards, thilo.
|
|
|
|
|
Hello,
How can I format the decimal output to 4 decimal points only?
Thank you.
|
|
|
|
|
Use the formatting in the ToString method:
string shortPi = Math.PI.ToString("0.0000");
---
b { font-weight: normal; }
|
|
|
|
|
// Create a NumberFormatInfo object and set several of its
// properties that apply to numbers.
NumberFormatInfo provider = new NumberFormatInfo( );
string formatter = "{0,22} {1}";
// These properties will affect the conversion.
provider.NegativeSign = "minus ";
provider.NumberDecimalSeparator = " point ";
// These properties will not be applied.
provider.NumberDecimalDigits = 4;
provider.NumberGroupSeparator = ".";
provider.NumberGroupSizes = new int[ ] { 3 };
Convert.ToString( ObjDouble, provider ) );
Live Life King Size
Alomgir Miah
|
|
|
|
|
Hi
I have the following problem: I generate an XML file that has a CDATA section that contains character references (characters created by the XmlTextWriter in order to conform to well formatted XML and are in the form: , ). When I read the xml with an XmlTextReader I get the escaped strings instead of the characters. (I get "" instead of '\0' for example)
using reader.ReadChars(...) has the same effect.
Any ideas?
TX
|
|
|
|
|
Hey all,
I'm new to web app dev so I'll ask a simple question..
I created a simple chat application with client & server sockets.
after initialation & establishing the connection, I send text message to the server.
when I send the first message, the server gets it and displays it,
now, I realized that after the client sends the first message to the server, I need to reconnect to it again in order to send another message(s)..
The question is Do I need to reconnect to the server everytime, even though I have the server & client socket objects initialized...
my client code is like this:
private void btnSend_Click(object sender, System.EventArgs e)
{
btnConnect_Click(sender, e);//without this proc. I can send only 1 msg
try{
string msg = TxtSnd.Text+"<eof>";
byte[] byteData = Encoding.ASCII.GetBytes(msg);
lblstts.Text = "Sendeing...";//status label
clientMe.Send(byteData);
TxtSnd.Text = "";//delete text from TextBox
}catch(Exception Ex)
{
MessageBox.Show(Ex.Message);
}
}
|
|
|
|
|
Hi,
It is possible to add a key to the c# dll so that
when other application call it, the application need
the key to use the dll ? And how to do that ?
Thanks
|
|
|
|
|
NewtonInTown wrote:
It is possible to add a key to the c# dll so that
when other application call it, the application need
the key to use the dll ?
The short answer is no.
The long answer is maybe. This is possible only if all the methods you write in this .DLL are written to accept a key and validate it. This is something I don't think you want to do in every property and method you expose.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
So long as both assemblies have a strong name, you can add a StrongNameIdentityPermissionAttribute[^] to the class library at the assembly level. As a result, only applications signed with your private key will be able to access the library.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
Hmmm... Didn't know about that one.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hello,
I have two decimal numbers, and I want to use mod function to get
an integer number. But it seems it's only available for SQL.
Is there a nice way of deviding two decimals and rounding off the result to a nearest integer?
Thank you
|
|
|
|
|
int x = Convert.ToInt32(10.0/2.4);
Live Life King Size
Alomgir Miah
|
|
|
|
|
Thank you,
I am so stupid I am already using Convert method.
|
|
|
|