|
Hello.
I want to make an array of several controls for example buttons in my windows application.
is that possible in VS 2005?
Thanks everyone.
Please, Send me an answers to t_nedelchev@abv.bg.
t_nedelchev@abv.bg
|
|
|
|
|
Sure you can. Simply declare the array and assign a new or existing Button reference to it.
Button[] buttonarray = new Button[5];
for (int i = 0; i < buttonarray.Length; i++)
buttonarray[i] = new Button(); If you create the buttons dynamically don't forget to add them to the controls collection of your form or any container in it, so they get displayed.
"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
|
|
|
|
|
Thanks for your fast reply, Stefan.
I wrote the code above.
this creates buttons, but they are invisible.
after your piece of code i wrote the following:
buttonarray.Location =...
buttonarray.size = ....
buttonarray.name = ...
buttonarray.tabindex = ...
buttonarray.text = ....
buttonarray.visible = ...
but again without success - there no buttons on my form.
what do i miss?
thanks.
|
|
|
|
|
As I said you have to add them to the controls collection of your form or any container in it. After all buttons are created, add the following line:
this.Controls.AddRange(buttonarray);
"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
|
|
|
|
|
Dear Stefan Troschütz, Thanks a lot. I made it.
|
|
|
|
|
hi i am try learn "push buttons events" & i stack on this.
i want on key ENETER push navigate on my pooor webBrowser
but this doesn work
1)
void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
// Navigate if the ENTER key is pressed
if (e.KeyChar == '\r')
Navigate();
}
2)
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if(e.Alt && e.KeyCode == Keys.E)
}
please tell me where prolem?
i am using VC#2005
tnx for help
i am noob in c#
|
|
|
|
|
At first I'm not really sure whether the keychar resulting from pressing enter is "\r". It would be better to check for it inside the KeyDown event handler e.KeyCode == Keys.Enter . This way you will also have your keyboard event handling in one place.
Secondly, are you sure the events are really fired (You may debug it)? Most probably your entering text in some other control, so the keyboard events of your form are only fired, if you set KeyPreview true. Either do this, or much better IMO register the KeyDown event handler to the control that's getting edited.
"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
|
|
|
|
|
i am type this
void Form1_KeyDown(object sender, KeyEventArgs e)
{
if(e.KeyCode == Keys.Enter)
this.webBrowser1.Navigate(this.toolStripTextBox1.Text);
}
0 errors 0 warnings
& nothink hepend
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
Athlon 64 3500+, Gigabyte GA-K8NXP-9, 2x512 DDR400 Kingston, Inno3d 6200 PCIe, SS2 B2C2 v2.6, HDD := 450gb, Genius 56k int, NEC DVD-RW и мать его Суньмастер 550.
|
|
|
|
|
As I said, if you're entering text in some other control (probably the toolStripTextBox1), the keyboard events of your form aren't fired unless you set the KeyPreview property true . So either do this, or much better IMO register the KeyDown event handler to the control that's getting edited (toolStripTextBox1) cause otherwise Navigate will be executed whenever you're pressing enter.
"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
|
|
|
|
|
all what i done its
private void Form1_KeyDown(object sender,KeyEventArgs e)
{
if(e.KeyCode== Keys.Enter)
this.webBrowser1.Navigate(this.toolStripTextBox1.Text);
}
then just swith in properties of textbox
http://b.foto.radikal.ru/0610/87852a0cf72a.gif
& all work thx a lot
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
Athlon 64 3500+, Gigabyte GA-K8NXP-9, 2x512 DDR400 Kingston, Inno3d 6200 PCIe, SS2 B2C2 v2.6, HDD := 450gb, Genius 56k int, NEC DVD-RW и мать его Суньмастер 550.
|
|
|
|
|
If the KeyDown event handler is now registered to the ToolStripTextBox you should rename, so its obvious which KeyDown event it handles.
private void ToolStripTextBox1_KeyDown(object sender,KeyEventArgs e)
Also it would be a good idea to give the ToolStripTextBox a more descriptive name e.g. "toolStripTextBoxUrl".
"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, everyone.
I make a program, which uses Serial port (COM1).
I'm working with VS 2005.
My problem is:
Is there any way or method to find out, if the COM1 port is already used from another application before i start my program?
Thanks a lot.
Please answer me to
t_nedelchev@abv.bg
t_nedelchev@abv.bg
|
|
|
|
|
AFAIK there's no other way than trying to open the serial port.
"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
|
|
|
|
|
Im making a WinForm GUI for a program that run in the command shell. The problem is that shell program has problems if the input arguments have spaces because after each space it thinks its a new argument. For example:
abc.exe D:\My Documents\myfile.xml
will give an error like Error: invalid command line argument: 'D:\My'
It will work if i use:
abc.exe D:\MyDocu~1\myfile.xml ok
So my question is that how can i get the old style "MyDocu~1" or from an OpenFileDialog.FileName that has "D:\My Documents\myfile.xml". I dont know the name of the style so i called it "old style"
The shell program has an output argument that will send the resulting file to that directory but i will have the same problem as the input file. I just may have to use the OpenFileDialog with File.Copy to copy the file to my program's directory and move with File.Move the resulting file to the same directory as the input file using the file path from the OpenFileDialog.
modified 16-May-21 21:01pm.
|
|
|
|
|
I'm not sure whether the so calles old style is the proper way to deal with white spaces. If I recall right its purpose was to deal with names consisting of more than 8 characters. From what In know you deal with white spaces by putting the path between double quotes:
abc.exe "D:\My Documents\myfile.xml"
Try if your shell program recognizes the file this way and if so simply prepend and append a double quote character to the OpenFileDialog.FileName.
"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
|
|
|
|
|
Wrap your path in double quotes and it should work
abc.exe "D:\My Documents\myfile.xml"
|
|
|
|
|
Hi, I have two datagridviews A and B. I want to set the bindingsource filter of datagrid B with the "Selected Row" of datagrid A. E.g. The customer name is in A, and the corresponding orders of that customer will show up in B.
Usually this would be done with the following code if I was using a ComboBox for A:
this.myBindingSource.Filter = "Name=" + myComboBox.SelectedValue;
But for a datagrid view all i can get is "myGridViewA.SelectedRows". How do I extract the selected row and the corresponding column value (Name) from SelectedRows?
A even better method would be how would this be done if Multi select is turned in datagridview A?
|
|
|
|
|
Just googling your question returned answers to your question. Try this site.[^]
A word of warning, I do not think you can have a master/slave relationship with multi select. But you can find out by trying.
|
|
|
|
|
i have been trying to add a Onclick event to this control throught Dispatch ID 0, entry point in an application, but that wont respond.what i intend to do is to get the html tag that generate the event,like a hyperlink or something, and through that get its id and all the attributes. can anyone help. anyother suggestion will be appreciated.
|
|
|
|
|
Hi,
I have a code fragment that handles dragging and dropping tree view nodes on each other, all in the same tree view.
All works fine, but i want to cancel the dragging operation when two mouse button are presses.
In MSDN is written:
"The QueryContinueDrag event occurs during a drag-and-drop operation and allows the drag source to determine whether the drag-and-drop operation should be canceled. A QueryContinueDragEventArgs specifies whether and how the drag-and-drop operation should proceed, whether any modifier keys are pressed, and whether the user has pressed the ESC key."
Well i put a break point in this event, but in runtime when i press on another button or press another key - nothing happened - that is - i execution does not reach the breakpoint.
I search over the internet, but NADA.
Any help will be appreciated.
elaj.
|
|
|
|
|
Please forgive what might seem to be a bit of spam, but I think this would be of interest to the folks here.
I recently published a book outlining the life of a Wall Street programmer, and everything you need to know to get a job as a programmer on Wall Street.
I have some free sample chapters here:
http://www.wallstreetprogramming.com
- Cheers
- Andrey
|
|
|
|
|
how can we fech data in an string array directly from dataset
dataset --> dataset11
table --> searchOnline
column --> url
string[] --> urlString
i want to directly get all the rows in column url came into the urlString
thanks
|
|
|
|
|
i tried this but it wont helped
<br />
url = new string[(dataSet11.SearchOnline.urlColumn.ExtendedProperties.Count)];<br />
dataSet11.SearchOnline.urlColumn.ExtendedProperties.CopyTo(url, 0);<br />
|
|
|
|
|
<br />
url = new string[dataSet11.SearchOnline.Rows.Count];<br />
name = new string[dataSet11.SearchOnline.Rows.Count];<br />
for (int i = 0; i < dataSet11.SearchOnline.Rows.Count ; i++)<br />
{<br />
name[i] = dataSet11.SearchOnline.Rows[i]["name"].ToString();<br />
url[i] = dataSet11.SearchOnline.Rows[i]["url"].ToString();<br />
}<br />
if i write the code as above
name and url array contains same data of url Column
else
if i write it like this then they both contains data from name column
<br />
url = new string[dataSet11.SearchOnline.Rows.Count];<br />
name = new string[dataSet11.SearchOnline.Rows.Count];<br />
for (int i = 0; i < dataSet11.SearchOnline.Rows.Count ; i++)<br />
{<br />
url[i] = dataSet11.SearchOnline.Rows[i]["url"].ToString();<br />
name[i] = dataSet11.SearchOnline.Rows[i]["name"].ToString();<br />
}<br />
please help me it is a true bug or its my mistake ???
|
|
|
|
|
<br />
url = new string[dataSet11.SearchOnline.Rows.Count];<br />
name = new string[dataSet11.SearchOnline.Rows.Count];<br />
for (int i = 0; i < dataSet11.SearchOnline.Rows.Count ; i++)<br />
{<br />
name[i] = dataSet11.SearchOnline.Rows[i]["name"].ToString();<br />
}<br />
for (int i = 0; i < dataSet11.SearchOnline.Rows.Count; i++)<br />
{<br />
url[i] = dataSet11.SearchOnline.Rows[i]["url"].ToString();<br />
}<br />
this solved the problem
but will you please tell me what is the concept behind this
|
|
|
|