|
Thanks for your help.
Unfortunately I am getting an error, and I think I have seen it before when I was trying to solve that problem, maybe because I have a class Students on a file students.cs
The error is:
Inconsistent accessibility: property type 'Studentstest.Students' is less accessible than property 'Studentstest.Data.Students'
Where Studentstest is the name of the project containing the following classes:
Form1.cs, Data.cs and Students.cs
|
|
|
|
|
OK, I found this
http://msdn.microsoft.com/en-us/library/532wtsbc%28v=vs.90%29.aspx
and corrected accordingly.
Thanks again.
modified 12-Jul-12 7:52am.
|
|
|
|
|
There's two common approaches I use for modal dialogs. The first is to write a method in StudentsDataForm (yes I just renamed your class ) which takes the Student, shows the form and returns a modified version:
public Student EditStudent(Student input){
this.firstNameTextBox.Text = input.FirstName;
if(DialogResult.OK == ShowDialog()){
Student result = new Student();
result.FirstName = firstNameTextBox.Text;
return result;
} else return input;
}
There's also a variant of this where you update the input object in place, and return the DialogResult, which you can use if you always want the data object to be updated by the form when OK is used.
The second way is to have a property in the second form:
public Student Student {
get {
Student student = new Student();
student.FirstName = firstName.Text;
return student;
}
set {
firstName.Text = value.FirstName;
}
}
Then you push the data into the form, and use the data from it if the user pressed OK:
studentDataForm.Student = someStudent;
if(DialogResult.OK == studentDataForm.ShowDialog(this)){
}
|
|
|
|
|
Hello and thanks for your help.
Of course it works that way, but assuming I have 10 different objects in the Main Form and I need their data in several other Forms of my programme, let's say 6 new forms, do I have to create similar objects of all those 10 in everyone of the 6 Forms?
Isn't there a way to make an object available in the whole programme?
modified 14-Jul-12 15:27pm.
|
|
|
|
|
Hi. I'm new to C# so sorry if my questions will be little simple or not so clear.
I have a DLL that I I'm using as a COM reference in my project.
In the DLL there is a method I'd like to use:
STDMETHOD(CS7ProSim::ReadOutputImage)( long StartIndex,
long ElementsToRead,
ImageDataTypeConstants DataType,
VARIANT* pData)
My problem is the "VARIANT* pData" and how to access the returned data in it. The result I want from the method is a byte array[1024].
I declared this variable
public partial class Form1 : Form
{
byte [] QB = new byte[1024]; //Define the data area
Then I'm using this code...
//Set up variables
Object pData = QB;
//Setup of method datatype
ImageDataTypeConstants pdtConst;
pdtConst = ImageDataTypeConstants.S7Byte; //Read in byte form
//Read from-to
int StartByte = 0; //Start on byte 0
int ReadSize = 1024; //Read 1024 bytes
//Call the method
ps.ReadOutputImage(StartByte, ReadSize, pdtConst, ref pData); //Read the whole image of 1024 bytes
The method will return the correct data in the pData array. But I don't want to have it in a object but in an array.
My questions are...
-Do I really have to create the new pData object or can I somehow use the QB directly in the method call?
-If I use pData as I do now, how can I copy the values in pData back to QB?
If I "hover" above the "pData" I can see it's a array like QB and it has the values from the method, but how to get those values back to QB?
Thanks.
|
|
|
|
|
Hello,
how can a service read a shared memory file "MemoryMappedFile" from a user application.
I have a closed Source application that have a public Shared memory file with data.
In a normal test application i can read the Memory Mapped File.
In a service the same failed. I can only read Shared memory data from applications that shared with the filename: "Global\\filename", not segments with "filename".
There is a chance to read Shared Memory Files without the "Global\\" mark in a windows Service from a normal application.
Sebastian
|
|
|
|
|
in my website there is a problem regarding the master page i can apply the autocomplete ajax externder to the master page then code is not work properly, the main thing is that can i use autocomplete externder to the master page in asp.net
Nitin Kadam
|
|
|
|
|
Although you may be coding in C#, the ASP.NET forum[^] may be better suited for your question.
|
|
|
|
|
Hi all,
If I want to have a login option on my home page without using javascript what are my choices. I can create a login page using asp.net but the problem is my home page would have an extension of .aspx and not .com or .net. I know that you could use a login page that is separate from the home page and then link to it but there has to be a way to have login on the home page. Please point me in the right direction, thanks in advance.
|
|
|
|
|
I can create a login page using asp.net but the problem is my home page would have an extension of .aspx and not .com or .net.
- You can set default page as Login.aspx in your site and you can access your website using .com and your pagename will not appear. You can also use URL Redirection if you do not want to display .aspx extension.
Hope this will solve your problem
Thanks
-Amit.
|
|
|
|
|
If you want to enforce authentication without writing server-side login scripting then you can set your web server up to require access control on that directory. Then you can put normal (.html) resources in there and people will get an authentication dialog when they first try to access it.
The extension of the page (.aspx, .php, etc) is entirely separate from the domain name, and for you not to know this makes me think you shouldn't be in charge of a website
|
|
|
|
|
Thanks for answering but that is not what I'm looking for. I already know about the method of authentication you mentioned. I did not want my home page to be directed to a different page and no dialog or popup of of any kind. Please read people's questions carefully before you decide to leave negative comments, and such comments do no one any good.
modified 11-Jul-12 9:48am.
|
|
|
|
|
Your question, however carefully read, does not mention 'no dialog or popup of of any kind'.
If you don't want the HTTP authentication prompt, you will have to use a scripting language to perform authentication (i.e. a login page or AJAX target) and access control on all the pages you want to be restricted. You can set a default page (usually default.aspx or index.php) which will be used when a user goes to the root URL. If you're using ASP.net (and I assume you are) then you can use the Membership API to authenticate.
To have an inline login on a page without using AJAX, you need to use a <form> and submit it to a script which processes it. That can be your normal login.aspx, and you can pass a redirect query parameter to it (using a hidden field on the form) which causes a successful login to be redirected back to the original page.
|
|
|
|
|
How can I delete a specific Excel File in my own directory using C#?
|
|
|
|
|
You already have the correct verb[^].
|
|
|
|
|
if (System.IO.File.Exists(physicalpath+filename))
{
System.IO.File.Delete(physicalpath+filename);
}
|
|
|
|
|
hello guys. I think this is the right platform to ask this question and am sure most of you must have worked in MFC / VC++ as well.
I want to know that how a control knows about its event handler ( and any associated variable)? Let's say I add an event handler OnClick_Save to the button named btnSave. How does this button knows about this event handler.
In MFC, this thing can be understood by having a look at MessageMaps and DoDataExchange().
Thanks for providing any detailed input or pointer on this issue.
This world is going to explode due to international politics, SOON.
|
|
|
|
|
It's a property of the object's class and managed internally by the .NET framework.
|
|
|
|
|
Under the hood (the topmost hood of many, that is) you subscribe a method to the control's OnClick event. In code that would mean something like
btnSave.Click += new System.EventHandler(OnClick_Save);
It's hidden away from you in the corresponding [InsertFormNameHere].designer.cs file.
The above mentioned "Click" holds a list of methods to call whenever the OnClick event is raised. You can also unsubscribe a method from that list. Or subscribe many methods (as a list would suggest).
This is a very basic explanation. I'm sure someone can provide more in-depth knowledge if required.
Ciao,
luker
|
|
|
|
|
Delegates hold a list of delegates (called an invocation list) which are called when the delegate itself is invoked.
The += YourMethod adds a delegate to your method to the event's (an event is just a specialized delegate) invocation list.
using System;
public class EventRaisingClass
{
public event EventHandler SomethingChanged;
public void ChangeSomething()
{
OnSomethingChanged(EventArgs.Empty);
}
protected virtual void OnSomethingChanged(EventArgs e)
{
EventHandler eh = SomethingChanged;
if (eh != null)
eh(this, e);
}
}
using System;
public class SubscribingClass
{
private EventRaisingClass eventRaisingInstance;
public SubscribingClass()
{
eventRaisingInstance = new EventRaisingClass();
eventRaisingInstance.SomethingChanged += EventRaisingInstanceSomethingChanged;
}
private void EventRaisingInstanceSomethingChanged(object sender, EventArgs e)
{
Console.WriteLine("Something Changed");
}
public void Update()
{
eventRaisingInstance.ChangeSomething();
}
}
In your example the Button is the EventRaisingClass, that code is part of the framework but operates in exactly the same way.
Warning: Because a reference to an item (method) of our subscribing class is now held in another class instance, it will not be eligible garbage collection until the raising class instance is collected. If you require the subscribing instance to be eligible for collection beore that time then you can remove the delegate from the event with -= YourMethod . Not needed often, but can cause suprises if you are not aware of this.
|
|
|
|
|
A fine explanation. One question though. How / Where Update() is called here?
This world is going to explode due to international politics, SOON.
|
|
|
|
|
It's not in the sample code, but it could be called from anywhere that has access to an instance of that class (or by code elsewhere within the class).
|
|
|
|
|
Hello everybody. im working on graduation project and i have trouble to locate and find iris image. where can i find libraries to find iris image? please answer this very important for me i must graduate this year but i can't finished my project yet.
|
|
|
|
|
A quick Google search for "face recognition" or "eye recognition" will probably find what you are looking for.
|
|
|
|
|
Hi All,
Firstly I don't want to post in wrong forum for set up, installer questions which this is I have posted here until I can find a more approiate forum on CP. I have an executable I have written/hacked with help to test for a driver, I would like to know how to ensure it gets excuted by the installer (this is related to question I asked Pete O'Hanland last week I am NOT trying to do anything nasty!).
Glenn
|
|
|
|