|
The error that was pointed out to you is still the case. If you create it in your constructor, locally, then it doesn't exist anymore in your load event. You should call the constructor in your load event. Scratch that. You buy a book on VB.NET, read it, work through it, and start another project when you've learned some basics. If you don't understand variable scoping, you frankly should not be writing code, sorry.
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 there
I need to be able to write logs to a network drive, but I cannot get the FileIOPermission to work,
I am using the code below
[CODE]
PermissionSet ps1 = new PermissionSet(PermissionState.None);
ps1.AddPermission(new FileIOPermission(FileIOPermissionAccess.Read | FileIOPermissionAccess.Write, m_LogFile));
ps1.Demand();
[/CODE]
but when I try to write to the file I get the following Error
[CODE]
Request for the permission of type System.Security.Permissions.FileIOPermission, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.
[\CODE]
What should I use instead????
Regards
Andres
"Learn from the mistakes of others.
You can't live long enough to make them all yourself."
"Failure doesn't mean I'm a failure, It does mean I have not yet succeeded;
Failure doesn't mean that I should give up, It does mean that I should try harder;
Failure doesn't mean that I will never make it, It does mean that I need more practice".
Thank you for helping.
|
|
|
|
|
I have a UserControl. When I instantiate it the UserControl reads in an image that it uses, it draws it underneath the cursor. If I programmatically add the UserControl to a form and then run the program it works perfect. However if I try to do this via design time support I get an error screen instead of a design time screen, the error is:
"One or more errors encountered while loading the designer. The errors are listed below. Some errors can be fixed by rebuilding your project, while others may require code changes."
The reason for the error is that it can't find my image file, because instead of looking for it in my programs folder it looks for it in the Visual Studio IDE Folder.
"Could not find file 'C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\images\tileselect.png'. " Is the exact error I get.
My original idea was to just remove design time rendering of the control, since it works just fine when I run it, but I couldn't figure out how to make it so that a control is not rendered when you use it in design time. Though design-time support is preferred.
Any help on this would be great. I am actually using a combination XNA/Windows Forms but from what I can tell that should have no bearing on the issue.
Source Code At Problem:
tileSelect = Texture2D.FromFile(GraphicsDevice, "images/tileselect.png");
If I remove this line, and the line that draws the sprite, it will work fine in Design time, it even calls the On_Paint event and runs the XNA code to clear the screen, not shown. Is there maybe some way I could rewrite my path so that it would look in my programs directory... No idea, thats why I posted here
Thanks in advance.
--Peter
|
|
|
|
|
Hi,
you can use Component.DesignMode to have another file path (or no file loading)
while in design mode...
|
|
|
|
|
Worked Great, thanks.
--Peter
|
|
|
|
|
Hello.
I have a windows forms application (.NET 3.0)
where I have a user control ( a sort of spine) on a Form (called imaginatively enough MainForm).
In the spine I make a call to a WCF service (in a seperate thread). I need to be able to (from this seperate thread) to call a method (DisplayNotification) on the MainForm and pass it a parameter (or two).
I just can't seem to do this. I am however able (with delegates) to do this with methods/controls on the spine. But unfortunate not the MainForm.
Can someone give me a leg up on this?
Basically:
Spine(usercontrol on MainForm) ->starts thread(WCF service) ->needs to access DisplayNotification() on MainForm.
I tried using FindContol() and even .Parent but I am embarassed to say...
I don't know how to use it. I can get a list of controls that match the control I want. I get it in a the form of ArrayOfFormControls[]. It's just that I don't know how to invoke properties on the say ArrayOfFormControls[0].
Can you point me towards an example? Basically I would prefer to use a METHOD in the MainForm to do my dirty work, rather than use properties on the control itself.
Some have mentioned using reflection, I'm afraid I have no experience with using reflection. Can you point towards an example or tutorial. I have googled it, and come up short....
There has also been talk of passing a reference to the mainform in the constructor of my usercontrol. Any concrete examples?
Thanks!
----------------------------------------
Code is sexy. Go get some.
|
|
|
|
|
Of course U can do that with the help of delegates.
In the main form create a delegate that calls the function in the mainform.
Pass the delegate as a parameter to a public function in the subform(just after creating the usercontrol).
The public function should assign the argument to a local delegate.
So, whenever U wish to call the mainForm function, call the local delegate
after checking for null.
Regards,
Arun Kumar.A
|
|
|
|
|
hi every one,
I am making a Windows application in C# 2.0 and I was trying to give the connection String dynamically to the dataset bcz it would contain sensitive information otherwise. That's bcz I'm using Sql Server Authentication to logon to the database.
@"Data Source=LEOPARD\ATECH;Initial Catalog=KPS;User ID =Rocky;
The password is yet to be given and as long as I dont give it this exception will not stop from comming. The dataset wizard asked the question of including the sensitive info (passwrd) in the connection string but I refused and it said that you'd have to add that programatically on ur own. So there's gotta be a way to do it somehow. Can any buddy plz tell me that?
thanks in advance,
Rocky
|
|
|
|
|
hi all,
i need to make an application that use a changable form's opacity
that when i change the value of a NumericUpDown control
the value of the form's opacity change
and that what i trayed to do
private void numericUpDown1_ValueChanged_1(object sender, EventArgs e)<br />
{<br />
this.Opacity =Convert.ToDouble(numericUpDown1.Value);<br />
}
but it didn'n work
the form's opicity didn't change
can i do what i need or that's not allowed in C#?
thanks in advance
and sorry for my English
|
|
|
|
|
adel_soli wrote: Convert.ToDouble
Here's your problem. The opacity is a value between 0.0 and 1.0. Your numeric up down control isn't showing doubles. Did you stop to think why it needed a double ?
this.Opacity = numericUpDown1.Value/100.0;
will work, assuming the range of the control is 0 - 100.
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 )
|
|
|
|
|
sorry christian
but it didn't work
it gives me the following error
Operator '/' cannot be applied to operands of type 'decimal' and 'double'
|
|
|
|
|
I would urge you to give up on this project, buy a book on C#, and work through it. The problem is simple - you need to cast one of these to double, or the other to Decimal, so they are both the same type.
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 )
|
|
|
|
|
of course i trayed to cast one of these
but it also didn't work
the opicty didn't change
|
|
|
|
|
Or maybe it only changed by a little bit?
this.Opacity = (double) numericUpDown1.Value ;
Using a numericUpDown1 that ranges from 0 to 1 with two decimal places.
|
|
|
|
|
Personally I think the Convert class is needless and confusing; it should be deprecated.
|
|
|
|
|
Hi All,
I have created a project that exports data to Excel. I take some samples and display it using excel. I have 4 columns: time, X, Y, Z data. The X,Y,Z data is integer data and exports perfectly. The time column doesn't work. I create the array and then I try to export it, but for some reason with double it changes all the array to the first time value .1s and if I have it as a string instead it changes all the values in the array to the final read value. Does anyone know how to display the time. I am taking a sample every 100ms so I am trying to do an elapsed timer. Please help. Below is my export to excel function:
<br />
private void button2_Click(object sender, EventArgs e)<br />
{<br />
timerTakeData.Enabled = false;<br />
radioButton10.Enabled = true;<br />
radioButton100.Enabled = true;<br />
radioButton20.Enabled = true;<br />
radioButton200.Enabled = true;<br />
radioButton50.Enabled = true;<br />
button1.Enabled = true;<br />
<br />
labelTime.Text = "0.00";<br />
Excel.Workbooks ExcelBooks;<br />
Excel.Sheets ExcelSheets;<br />
Excel._Worksheet ExcelSheet;<br />
Excel.Range range;<br />
timerTakeData.Enabled = false;<br />
radioButton10.Enabled = true;<br />
radioButton100.Enabled = true;<br />
radioButton20.Enabled = true;<br />
radioButton200.Enabled = true;<br />
radioButton50.Enabled = true;<br />
button1.Enabled = true;<br />
<br />
labelTime.Text = "0.00";<br />
Excel.Workbooks ExcelBooks;<br />
Excel.Sheets ExcelSheets;<br />
Excel._Worksheet ExcelSheet;<br />
Excel.Range range;<br />
try<br />
{<br />
ExcelApp = new Excel.Application();<br />
ExcelBooks = ExcelApp.Workbooks;<br />
ExcelBook = ExcelBooks.Add(Missing.Value);<br />
ExcelSheets = ExcelBook.Worksheets;<br />
ExcelSheet = (Excel._Worksheet)ExcelSheets.get_Item(1);<br />
<br />
ExcelSheet.Cells[1, 1] = "Time";<br />
ExcelSheet.Cells[1, 2] = "X A/D";<br />
ExcelSheet.Cells[1, 3] = "Y A/D";<br />
ExcelSheet.Cells[1, 4] = "Z A/D";<br />
ExcelSheet.get_Range("A1", "D1").Font.Bold = true;<br />
ExcelSheet.get_Range("A1", "D1").VerticalAlignment = Excel.XlVAlign.xlVAlignCenter;<br />
<br />
range = ExcelSheet.get_Range("A2", Missing.Value);<br />
range = range.get_Resize(cnt, 1);<br />
range.set_Value(Missing.Value, time);<br />
range = ExcelSheet.get_Range("B2", Missing.Value);<br />
range = range.get_Resize(cnt, 1);<br />
range.set_Value(Missing.Value, xVolt);<br />
range = ExcelSheet.get_Range("C2", Missing.Value);<br />
range = range.get_Resize(cnt, 1);<br />
range.set_Value(Missing.Value, yVolt);<br />
range = ExcelSheet.get_Range("D2", Missing.Value);<br />
range = range.get_Resize(cnt, 1);<br />
range.set_Value(Missing.Value, zVolt);<br />
ExcelApp.Visible = true;<br />
ExcelApp.UserControl = true;<br />
}<br />
catch (Exception theException)<br />
{<br />
String errorMessage;<br />
errorMessage = "Error: ";<br />
errorMessage = String.Concat(errorMessage, theException.Message);<br />
errorMessage = String.Concat(errorMessage, " Line: ");<br />
errorMessage = String.Concat(errorMessage, theException.Source);<br />
<br />
MessageBox.Show(errorMessage, "Error");<br />
}<br />
cnt = 0;<br />
clockCnt = 10.0;<br />
}<br />
|
|
|
|
|
i want to know how to use (wpf)....
|
|
|
|
|
|
Does google not work where you live ?
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 all,
I am trying to do a simple math division function. I am trying to divide 10/100.
This is the line of code:
double test = 10/100;
I always get 0. I want to be able to get .1, what am I doing wrong? Please help!
|
|
|
|
|
double d = 10.0 / 100.0;
led mike
|
|
|
|
|
Hi,
10/100 is an integer expression, its value is positive and less than one, hence zero.
The fact that you want to assign its value to a double is irrelevant during
the evaluation.
|
|
|
|
|
So to make 10/100 result in 0.1 , U can use 10.0/100 or 10.0/100.0 as they said.
But, if it is a variable like:
int a=10,b=100;
then U will have to typecast it like
a/((double)b).
Regards,
Arun Kumar.A
|
|
|
|
|
Does anyone knows a software that emules the Pocket at PC?
Something like: I link the Pocket at the PC and I use the pocket from PC.
??
Thanks all..
Att.
|
|
|
|