|
Hi,
I want to write a report designer but I don't know where I must begin .
Please help me.
Thanks
|
|
|
|
|
Hi, I just wish to know if exist some way of inicialize a vector (all positions) with the same value, without doing any for....
|
|
|
|
|
You'll need to be a bit more specific. C# doesn't actually have a class named Vector. It has ArrayList and List<t> which are essentially vectors (just don't have the name).
What value do you want them to be initialized to?
Jared Parsons
jaredp@beanseed.org
http://spaces.msn.com/members/jaredp/
|
|
|
|
|
here's what I'm sure is an easy one...
I have a project with 5 different windows forms. One is the main program form and 4 of them are displayed by clicking a button on the main form. I'm trying to get each form centered on the main form (they are all modal dialogs). I've chosen "center on parent" on the property sheet for each form, but each form is still spawning what seems to be randomly on screen. I don't think that the main form of the project is set as the parent form for each of the other forms. Is this what the problem is and if so how can I go about giving each form a child relationship to the main form?
Thanks,
John
BTW I'm using Visual Studio 2005 Standard Edition.
-- modified at 21:06 Friday 9th December, 2005
|
|
|
|
|
You are correct. For them to properly center they must have the parent form set. To do this just pass in the parent form as the first paramater to the ShowDialog() method. For instance
public void OnButtonClick(object sender, EventArgs e)<br />
{<br />
SomeForm child = new SomeForm();<br />
if ( DialogResult.OK == child.ShowDialog(this) )<br />
{ <br />
...<br />
}<br />
}
Jared Parsons
jaredp@beanseed.org
http://spaces.msn.com/members/jaredp/
|
|
|
|
|
Thanks a bunch Jared, got it working
Thanks,
John
|
|
|
|
|
:confused Hi,
I'm probably going to get hammered for this-- but here goes........
I'm trying to learn how to debug programs. Specifically, Windows Form Apps.
VS .NET 2003
I've found two kinds of tutorials:
Type 1: Tells you how to set a breakpoint
Tells you how to step in, step out etc.
How to set a watch window etc..
Type 2: Tells you stuff that is so advanced that it's of
no use for "practical" learning... "eax", "stack trace".
Sure, lots of people know this stuff, but what the heck do you do if you don't?
ps- I know what "eax" and a "stack trace" are but it hasn't helped me
learn how to use the debugger.
So here's the fundamental problem I'm having-->
I design a WinForm w/ buttons, TextBoxes, graphs etc...
The program compiles. I run it. Something doesn't work right.
I decide to debug it.
I decide to set a breakpoint.
I run "debug"
The WinForm launches (or doesn't launch until a few "step over" clicks)
And now the "step over" icon and it's friends are "grayed out". Now I'm in this frozen state between
the WinForm and the debugger window with no idea what to do...
Now what? How do I productively use the debugger and also "work" with the
events that fire and make things happen that I can see?
Thanks in advance.....
|
|
|
|
|
SkunkedWorks wrote: Type 2: Tells you stuff that is so advanced that it's of
no use for "practical" learning... "eax", "stack trace".
Debugging can be very advanced and difficult. IMHO the best way to learn is to
- try
- fail
- figure out why you failed
- repeat
SkunkedWorks wrote: And now the "step over" icon and it's friends are "grayed out". Now I'm in this frozen state between
the WinForm and the debugger window with no idea what to do...
Not sure what state you've gotten into here but pressing F5 should get you running again
Jared Parsons
jaredp@beanseed.org
http://spaces.msn.com/members/jaredp/
|
|
|
|
|
Hi All...
I writing some application that in it i have dynamic creating button.
In this case i created one method that will call in each button click.
How can i know what button was press ??
I want to save each button in Hash table and by the method "GetHashCode" to get the number of the button that was press.
But i don't know how to "Set" hash code ...
Someone can help me ?
Thanks.
|
|
|
|
|
Okay, with your idea, you can do the following when you create the buttons, assuming you have a Hashtable named buttonDict and an int named buttonIndex:
Button b = new Button();
b.Text = "Button " + buttonIndex.ToString();
buttonDict[ b ] = buttonIndex;
buttonIndex++; and, then, in your event handler
private void AllButton_Click( object sender, System.EventArgs e )
{
int clickedButtonIndex = -1;
if( buttonDict.ContainsKey( sender ) )
{
clickedButtonIndex = Convert.ToInt32( buttonDict[ sender ] );
}
} However, I think that you're keeping around a Hashtable for no reason. You could, alternatively, do the following in the place where you create your buttons:
Button b = new Button();
b.Text = "Button " + buttonIndex.ToString();
b.Tag = buttonIndex;
buttonIndex++; and in your general button click event handler:
private void AllButton_Click( object sender, System.EventArgs e )
{
int clickedButtonIndex = -1;
Button b = ( Button ) sender;
if( b.Tag != null )
{
clickedButtonIndex = Convert.ToInt32( b.Tag );
}
} I hope that answers your question sufficiently.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Hello, everyone, I have and application that start when the windows(2000) start, every time that the application run read the directory and put it in the registry, i have installed the program in c:\safeupdate\directory.exe but when the application star with windows the directory is c:\documents and setting\administator\directory.exe WHY?, How can i obtain the real directory?, my code is the next:
Private void Form1_Load(object sender, System.EventArgs e)
{
string pathNow = Directory.GetCurrentDirectory()+@"\directory.exe";
Registry.LocalMachine.OpenSubKey(@"software\microsoft\windows\currentversion\run",true).SetValue("directory",pathNow);
}
I need the real directory because in the registry put the wrong directory and the next time won't run the application because doesn't exist inthe c:\document and setting\directory.exe, please help me.
Greetings from Tijuana Mexico
|
|
|
|
|
RobertoTjMx wrote: string pathNow = Directory.GetCurrentDirectory()+@"\directory.exe";
Try replacing the above line with the following:
string pathNow = Application.ExecutablePath;
Or, with the following:
string pathNow = Application.StartupPath + "\\directory.exe";
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
Thanks, I solved my problem.
|
|
|
|
|
Application.StartUpPath
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
i try to make HttpWebRequest
with this code
----------------------
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.elections.ps/afindcenter.aspx");
request.Credentials = CredentialCache.DefaultCredentials;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream receiveStream = response.GetResponseStream();
-----------------------------
when i test it in localhost it work %100
but when i upload it to my host i recive this error message
***********************
Exception Details: System.Net.WebException: The remote server returned an error: (401) Unauthorized.
Source Error:
Line 36: // Set credentials to use for this request.
Line 37: request.Credentials = CredentialCache.DefaultCredentials;
Line 38: HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Line 39:
Line 40: // Get the stream associated with the response
Palestine
|
|
|
|
|
Can you give us more information about the host? Specifically do you know what process your app is running under? Also what is your relationship with the specified website?
CredentialCache.DefaultCredentials is essentially the credentials your application is running is. When you run it on your local box, this represents your credentials. If your host (I'm assuming it's a WebServer somewhere) is running as a completely different user so this would have a different value and explain why you are denied access
Jared Parsons
jaredp@beanseed.org
http://spaces.msn.com/members/jaredp/
|
|
|
|
|
information about the host?
i use hostingrightnow.com hosting with .Net 2.0
relationship with the specified website?
no relationship but this web site any one can open it (normal web site) as yahoo gmail and in my local host i can open without any CredentialCache but i see it mircrosoft web site and in use it
Palestine
|
|
|
|
|
Tareq Abuzuhri wrote: my local host i can open without any CredentialCache but i see it mircrosoft web site and in use it
In this case, since the end result is that the app will be hosted on a web site you probably don't want to do this. All having that line does is enable NT and Kerberose authentication. Since this is a public website you don't need to add that line.
I'm not sure why you are getting that error then. The only explanation I can come up with is that http://www.elections.ps/afindcenter.aspx is actively denying your host. I don't know of any good way to determine if that is the case or not though.
Jared Parsons
jaredp@beanseed.org
http://spaces.msn.com/members/jaredp/
|
|
|
|
|
On my form (MainWindow) I have a TabControl called MonitorTabs. I programmatically add a tab to it for each user I want to monitor. Then I add a user control called Monitor that contains a group of controls including a timer (RefreshTimer) to that tab.
From MainWindow, I call a function that needs to reset the interval on RefreshTimer on the currently selected tab. The number of RefreshTimers is dynamic, one for each User Control/Tab, and I don't know how to access any of them let alone the one that is currently selected. The timer is set to public, and still nothing shows up.
Can anyone help?
|
|
|
|
|
What you are asking is how to access the currently selected tab? If yes, the following line of code popups a MessageBox with the text of the currently selected tab:
MessageBox.Show(this.tabControl1.SelectedTab.Text);
If I understood otherwise, please try being a bit more specific with your question
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
Sorry I wasn't clear enough.
On each tab is a user control called Monitor. So if I have three tabs, then there are three Monitors. Monitor has various elements including a timer, a datagridview, a treeview, etc... since they are part of the same user control, they are all named the same.
So for example, I want to set refreshTimer on Monitor on tab 2 (the currently selected tab). How would I access that refreshTimer.
I have tried the following without success
MonitorTabs.SelectedTab.Monitor.refreshTimer<br />
MonitorTabs.SelectedTab.refreshTimer<br />
MonitorTabs.TabPages[MonitorTabs.SelectedIndex].Monitor.refreshTimer
Thanks
|
|
|
|
|
Hmm... if I get it right, I would keep track of each Monitor's instance name on each tab (e.g. I would add "Monitor1" on tab1, "Monitor2" on tab2 and so on. Then, in order to access them, I would locate them by their names).
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
That makes sense but I've never tried that before (somewhat new at this), could you demonstrate please? This is my current code.
TabPage newMonitorTab = new TabPage(TabTitle);<br />
MonitorTabs.TabPages.Add(newMonitorTab);<br />
<br />
MonitorTab monitor = new MonitorTab();<br />
newMonitorTab.Controls.Add(monitor);
Thanks!
|
|
|
|
|
You could write something like this:
TabPage tab1 = new TabPage("Tab 1");
MonitorTabs.TabPages.Add(tab1);
MonitorTab monitor1 = new MonitorTab();
tab1.Controls.Add(monitor1);
TabPage tab2 = new TabPage("Tab 2");
MonitorTabs.TabPages.Add(tab2);
MonitorTab monitor2 = new MonitorTab();
tab2.Controls.Add(monitor2);
This way, you know that tab1 has monitor1 on it, and tab2 has monitor2. So if the selectedTab is tab1 then you access monitor1 by writing something like this.monitor1
Hope this makes sense.
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
Its getting closer, I have added them and can access them to a point using the following:
MonitorTab monitor = new MonitorTab();<br />
monitor.Name = "Monitor" + MonitorTabs.TabPages.Count.ToString();
But I still can't access that control except using a foreach looping through the controls on the tab, which doesn't allow me to access the timer. Any suggestions?
|
|
|
|