|
Is there any way possible to make a textbox with a unchangable string in it ->
like a timebox (in windows time) with "19:23:23", which you can change only the numbers but cannot touch the ":"?
|
|
|
|
|
You want a masked edit text box. There are plenty of third party ones and examples of creating them here.
2.0 has a masked edit textbox as a built in control if you can wait that long.
|
|
|
|
|
Looking for info/code/tutorial on how to get the information that is supplied on a printer test page using C# (or C++/VB). Things such as the total number of pages the printer has printed, the total printer memory, etc. I tried using the WMI printer object (Win32_Printer) but it does not provide the number of pages prior to the last reset, while the printed test page directly from the printer does.
Thanks
|
|
|
|
|
There is nothing in the Win32 API that will do this. You must get this information directly from the printer, more than likely over TCP/IP. But the procedure used will vary from printer to printer and manufacturer to manufacturer.
At best, you'll have to get this kind of information from the printer driver. You'll need the doc on the driver (good luck!) to find out if it exposes any kind of API you can use.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thank you for the response , although it does complicate things a bit, it does set me in the right direction as well. I guess I'll have to get the printer driver from the Win32_Printer object, then for each type of printer driver use its API to retrieve pages printed.
Thanks again
|
|
|
|
|
Neomaya wrote:
I guess I'll have to get the printer driver from the Win32_Printer object
Won't happen. You don't "get" the driver from Win32_Printer. WMI won't help you in doing this project at all.
You'll have to make direct DeviceIOControl calls to the driver. That's why I said you'll need the docs on the driver, which will probably be very difficult to find, if at all.
Also, the API calls between drivers will NOT be the same. Manufacturers, and even different models, will have differing command structures, so writing some generic code won't work. You'll have to write specific code for each manufacturer and, in some cases, driver you want to support.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
If anyone could help me with this exception I'd be very grateful. I can't figure out why I'm getting it.
I'm working with an MDI application. I'm just trying to close the child form with a cancel button. Here's the code:
private void btnCancel_Click(object sender, System.EventArgs e)
{
theParent.hasSetupCostTracker = false;
this.Close();
}
The variable "theParent" is defined as a public variable and in the constructor of the form I have the code:
theParent = (frmCostTracker)this.MdiParent;
hasSetupCostTracker is simply a boolean public variable of the parent form taht I use to make sure that no more than one of this type of child form is open at a time.
If I take out "theParent.hasSetupCostTracker = false;" then the code works find and doesn't throw any exceptions.
Can anyone explain this error and/or give me a good workaround? Thanks!
(oh yeah, and the exact error message that I get is:
An unhandled exception of type 'System.NullReferenceException' occurred in Benefit Select Application.exe
Additional information: Object reference not set to an instance of an object.)
The ends can never justify the means. It is the means that determine the ends.
|
|
|
|
|
Run debugger and track the value of ur theParent object. Are u sure it's not empty? I mean, r u sure abt ur casting in the constructor? Check if it contains the expected value.
|
|
|
|
|
Thanks for responding.
I ran the debugger and double-checke that the theParent object is not empty. It's not.
The value I get for it is:
Benefit_Select_Application.frmCostTracker frmSetupNewCostTracker01.theParent
Trying to track down the problem I also tried adding the line:
MessageBox.Show(theParent.hasSetupCostTracker.ToString());
in the cancel button method to see if I could at least access the value of the hasCostTracker variable. I got this error:
Cannot pass 'Benefit_Select_Application.frmCostTracker.hasSetupCostTracker' as ref or out, because 'Benefit_Select_Application.frmCostTracker.hasSetupCostTracker' is a marshal-by-reference class
I have no idea what a "marshal-by-refernce" class is.
OK - while I was typing this message I tried something else, and now it works. I copied the line from the constructor
(theParent = (frmCostTracker)this.MdiParent;) into the cancel button method. So now it works.
But I'm still curious, do you know why the exact same code successfully initializes the reference in the cancel_button method but not in the constructor (there's only 1 constructor).
Thanks for your help.
The ends can never justify the means. It is the means that determine the ends.
|
|
|
|
|
Can someone pls tell/show me how to minimise a window/form to the taskbar.
|
|
|
|
|
When, I say taskbar, I mean the system tray, where the part of task bar where date, time, and Icons are displayed at the right hand corner.
ty.
|
|
|
|
|
Search CodeProject for NotifyIcon. When minimized, set the NotifyIcon of the form, and set the forms "ShowInTaskbar" property to false.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Homosexuality in Christianity
Judah Himango
|
|
|
|
|
ty u guys.
Never mind. I've solved it.
I went thru the online docs.
|
|
|
|
|
I want to learn the best practics to implement applications using layers. I already search on the web, but i still confused. Does anyone can teach me those pratices, redirect me for a site, something that could show me how to do it, and do it weel, samples, something precise?
Thanks
|
|
|
|
|
|
|
i made a mistake in the code
the correct code is
my application works like this,i have a datagrid,a dropdownlist and a submit button,my
dropdownlist contains a list of intervals eg(100-999)(2100-2199),in order for the user to
add to the grid he has to choose an interval from the dropdown,and the id for the row he's
adding has to be in that particular interval.
i have a method/function that checks if the id is in the chosen interval
private void checkvalue(int value)
{
switch(DropdownList1.SelectedIndex)
{
case 0:
if(value>=100 && value<=999)
{
}
else
{
Label1.Text="id not in required interval"
}
break;
case 1:
if(value>=2100 && value<=2199)
{
}
else
{
Label1.Text="id not in required interval"
}
break;
}
and the button clickevent
private void ButtSubmit_Click(object sender, System.EventArgs e)
{
checkvalue(num);
//adding to the grid
collection.add(num);
...
}
when i click my submit button ,and into the checkvalue callfunction,if the value is not in
the required interval ,it prints the text message but still continues to add the row to my grid
i want it to stop after it prints the message and exit without adding the row to my grid,what do
you suggest i do.i hope this is clear enough
thanks
regards paula
|
|
|
|
|
|
You need to return a boolean (true or false) from the checkvalue method
private bool checkvalue(int value){
if (the value is in the range){
return true;
} else {
return false;
}
}
//that's it.
Dirk Watkins
|
|
|
|
|
The answers 10 messages below were not good enough so it was essential to repost the same question?
|
|
|
|
|
Hi.
I have a requirement to store files (they happen to be .pdf files but could be word/excel etc) on an application server.
These files are to be requested from the presentation layer.
When the user clicks a report, a reportid is passed to the middle tier, whereby it retrieves the associated filepath from the DB and then goes and loads the file.
My problem is that I am not sure how to pass this file back to the presentation layer. What I would like to do, is spit out a stream to the response object so the file just opens in the users browser (rather than saving a copy on the web server and then allowing the user to either Open/Save).
I thought a filestream or binaryreader object would do the trick, but if i pass this to the presentation layer, the second i call the .Read methods, ill get an exception as the file doesnt exist on the web server !
Can anybody suggest the best way(s) of achieving my goals ?
Thanks.
|
|
|
|
|
You make no mention what your presentation layer is, however from the context I assume you mean a web page.
If you set the Response.ContentType to the proper file type and use Response.OutputStream it should work.
|
|
|
|
|
Sorry, yes, an ASP.Net web page. Im am OK with sending the stream to the response object once ive got it...my problem is actually getting the stream object from the middletier in the first place.
PresLayer - Requests doc id 1
AppLayer - Receives Request
- Obtains the path of the file from the db
- can open the file (filestream?)
- RETURNS THE FILE/STREAM
PresLayer - Spits stream out to response object.
My question is how i can pass the binary data back from the applayer to the preslayer. Eg, surely if i pass the filestream back (as an out parameter for example), the minute i call .Read on the front end, ill get an exception because the file actually exists on another machine ?!
|
|
|
|
|
Provided that permissions are set correctly you should be able to read the file into a stream and pass it to your presentation layer for display via Response.OutputStream
|
|
|
|
|
y dunn u pass a byte array frm the Business Layer to the presentation layer? Read the contents in the business layer into a byte array and pass that array to the presentation layer and use ur logic to display the content.
|
|
|
|