|
Hi all
I was wondering if there's any limit to the windows controls? I recieve the following error "Error creating window handle." while trying to databind a treeview to textbox.
Thanks ppl
|
|
|
|
|
Yes there is a limit to the number of handles in Windows and Windows NT, the former being much lower but still impractical to ever reach. This is most likely not your problem.
The problem is, most likely, that a TextBox is not a container control. The use of "databind" is also not possible in this context, since neither represents data.
Please post relevent code so that we can help you diagnose the problem you're having, since the discription you've given doesn't have nearly enough information to form any decent diagnosis.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Ok here's the code where it happens
This works fine
"this.textBox_ClsId.DataBindings.Add(new Binding("Text", ((DataSource)this.treeView_WorkView.SelectedNode.Tag), "Datamember"));
this.textBox_ClsIdentifier.DataBindings.Add(new Binding("Text", ((DataSource)this.treeView_WorkView.SelectedNode.Tag), "Datamember"));
this.textBox_ClsDescription.DataBindings.Add(new Binding("Text", ((DataSource)this.treeView_WorkView.SelectedNode.Tag), "Datamember"));
this.textBox_ClsVersion.DataBindings.Add(new Binding("Text", ((DataSource)this.treeView_WorkView.SelectedNode.Tag), "Datamember"));"
This is the only line giving me the error "//this.textBox_ClsExtends.DataBindings.Add(new Binding("Text", ((DataSource)this.treeView_WorkView.SelectedNode.Tag), "Datamember"));"
This is also working fine
"this.checkBox_ClsAbstract.DataBindings.Add(new Binding("Checked", ((DataSource)this.treeView_WorkView.SelectedNode.Tag), "Datamember"));
this.checkBox_ClsNew.DataBindings.Add(new Binding("Checked", ((DataSource)this.treeView_WorkView.SelectedNode.Tag), "Datamember"));
this.checkBox_ClsSealed.DataBindings.Add(new Binding("Checked", ((DataSource)this.treeView_WorkView.SelectedNode.Tag), "Datamember"));"
thanks
|
|
|
|
|
What's a DataSource , and what's the "Datamember"? Please don't post pseudo-code since it typically doesn't show the error. If DataSource is actually a class you created then please explain it, otherwise please use the actual class. For "Datamember" it's not so much important, but specifying such information should not be any sort of breach. If someone wanted to see your code, they'd just have to disassemble or decompile it with a slew of tools already available, including ildasm.exe that ships with the .NET Framework SDK.
If DataSource is a class besides a DataSet , DataTable , DataView , or DataViewManager derivative, then you're using property bindings. What type is the property that is returned from whatever "Datamember" represents in that line? If it is a data or data-derived class from those listed above, what type of data does the column represented by "Datamember" in that line represent, and is it returning DBNull (or null , if a strongly typed DataSet )?
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I apologize for not providing the correct information. The datasource is a class and the class name is "Class" and the datamember is "Extends". I found out that the datamember "Extends" was not assigned. Again I apologize but I'd like to say thank you for the help.
Thanks
|
|
|
|
|
Hi
there is a requirement to find some solution to make PDF secure that is if one opens in Acrobat,he can not 1)Print 2)Save and Copy(Ctrl+C) any part of document..
is there any solution in .NET?
-adnan
|
|
|
|
|
Such a solution would not be a .NET solution, but a solution using the PDFs themselves, since a PDF viewer is what is viewing the document. Adobe has had this capability for many years now and you should just buy Adobe Acrobat (the full version, not the reader - which does honor the DRM of the PDFs). See http://www.adobe.com/security/main.html[^] for more information.
I am not familiar with any .NET PDF writers that have the DRM capabilities, so you'll need to use Acrobat to do so. For that, read the documentation included with Acrobat since this is not a .NET solution.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
These are normal document properties of a .PDF file. When Acrobat creates the file, security properties can be written in to do exactly this. Now, if your using a 3rd party component to generate and write the .PDF file, you'll have to get with that components manufacturer to see what kind of support they offer to do this and how you can programmatically get to it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I'm trying to use WIA for the scanning of an application yet i don't want the default UI it provides and would also like to be able to pre-set the properties for the scan.
I've been looking at the article on here about WIA:
http://www.codeproject.com/dotnet/wiascriptingdotnet.asp
I've been able to change the code so it cuts out the UI and just gets the scan, however i'm having trouble trying to set the properties for the scan, one comment on the article says that you can use 'GetPropById' to do this yet i've so far had no luck, has anyone got experience with using this or can see a way of being able to pre-set the properties?
|
|
|
|
|
*How to monitor a printer queue from C#
*Get a handle to the printer you want to monitor
====================================================================
HI Experts,
how are you .hope you all will be fine.. i have started that i have to work on C#.well sir my project in which my main motto is to pause,cancel, and delting a job.. i have done the RND of this topics and methods used in the project...
Well sir now i am in the way that i have to know about the event handlers,event watcher for the printjobs or printers.In other words that when the user give the command of printjob then this job is watched by the event watcher and the information of printer i.e printer handler is given to the the event handler like jobid and according to this watching information of job the users jobs should be pause,cancel or delete the job.I have to handle with event wathcer , not from the button of the form,,because the job should be captured as before the printer starts and the action i.e performed pause or delete or resume .Now i am on the phase that i have to start working on handlers ,needs yours help.Waiting for yours reply .
With Regards,
Ishtiaq Ahmed
|
|
|
|
|
i made dialog with datagrid, now how do i set DialogResult.OK when i doubleclick on datagrid,
it's easy with button, ..hmm ..can you help me please
|
|
|
|
|
Create a handler for the DoubleClick event of your Datagrid and assign the wanted member of DialogResult enumeration to the DialogResult property of your Form :
private void dataGrid1_DoubleClick(object sender, System.EventArgs e)
{
this.DialogResult = DialogResult.OK;
}
www.troschuetz.de
|
|
|
|
|
thx!
|
|
|
|
|
Hi there,
Could anyone point me in the right direction... I'm trying to create a simple application that uses reflection to inspect objects at runtime. I dont want to use the Property Grid because i want to save the results to a text file. I cant find any example code that shows how to do this.
Thanks
Rohan
|
|
|
|
|
Your question isn't very clear. Do you need help with reflection, an alternative to the property grid, or how to write a text file?
|
|
|
|
|
The problem is with the reflection, i want to replicate the functionallity of the property grid with respect to viewing the different properties and their values.
Thanks
Rohan
|
|
|
|
|
You can use any number of list-based controls to display your information. A ListView, DataGrid, or any similar control would work to display. You can always write your own control or inherit from an existing control to provide specific features you need. The System.Reflection namespace is rich enough that it really doesn't matter how you display an properties and values.
|
|
|
|
|
The PropertyGrid doesn't actually use reflection, but various System.ComponentModel interfaces, like the ICustomTypeDescriptor interface, which you can read[^] about in the .NET Framework SDK. If the interface isn't implement by a component, the default behavior used by the TypeDescriptor which the PropertyGrid makes calls to is to use reflection, but reflection is not used directly (otherwise most of the design-time capability you enjoy in VS.NET and other IDEs would not be possible).
If you want to bind controls to your objects using their properties, read the documentation[^] for the PropertyManager class. You can use an array of objects of the same type (if not, the first type is used for binding information) similarily to how you'd use a DataTable or DataSet to bind, only you specify property names instead of column names.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi!
I am trying to make use of the new Enterprise Library application blocks in the re-write of a legacy system. The rewrite involves being able to access new C# modules from Delphi and as a result, we have decided to use COM to allow Delphi to access the C# objects, which are registered as COM objects.
Here is the code for a C# class that 'wraps' the Enterprise Library Cryptography application block:
///
/// COM wrapper for Enterprise Library Cryptography Application Block.
///
[ClassInterface(ClassInterfaceType.AutoDual)]
public class CorpITCryption
{
public string Encrypt(string aPlainText)
{
return Cryptographer.EncryptSymmetric("symprovider", aPlainText);
//return "Hello!";
}
public string Decrypt(string aCipherText)
{
return Cryptographer.DecryptSymmetric("symprovider", aCipherText);
}
}
This library class references the Microsoft.Practises.EnterpiseLibrary.Security.Cryptography .DLL and has Register For COM Interop set to True.
Here is the Delphi code that I am using:
procedure TForm1.Button1Click(Sender: TObject);
var
V: Variant;
begin
V:= CreateOleObject('CorpITCOMCryption.CorpITCryption');
edCipher.Text := V.Encrypt(edPlain.Text);
end;
I find that if I try to use other ways of accessing the COM object (ie by calling Co...Create() ) then I get a class not registered error in Delphi. The above method seems to work most regularly.
My actual problem is that I get an error in Delphi with the above version of the C# class library. The error text is as follows:
There was an error reflecting type 'Microsoft.Practises.EnterpriseLibrary.Security.Cryptography.Configuration.CryptographySettings'.
If I swap the comments on the Encrypt method and return a basic string, there is no error at all.
What am I doing wrong? What do I need to do to fix this?
Any help would be most appreciated.
Thanks
Andrew
|
|
|
|
|
Exposing .NET Framework components to COM should not be taken lightly. Never use auto-generated interfaces, always attributes your classes and interfaces with distinct GuidAttribute values, and many more things I've said in the past, which you can find by clicking "Search comments" above and search for "com interop". You should also read Exposing .NET Components to COM[^] here on CodeProject. When not using auto-generated class interfaces (which can lead to invalid VTBL binding or using the wrong cached dispatch IDs, if appropriate) you must declare the interface yourself and implement the class interface as the first interface in the interface implementation list when declaring your class.
Once you have followed these rules, so that your CLSIDs and IIDs don't change every time you compile (it's hard to hit a moving target, which is what you're doing now), you need to run either "regasm.exe assembly" is assembly is in the GAC, or "regasm.exe /codebase assembly" if not, which registers the full path to assembly in the InProcServer32 registry key for the CLSID in the registery.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
hi all,
I am new to Print data using C#.Can any body tell me how to print data Row in a Database Table using C#?.
I want to Print that data like report view.
Thanks in advance..
|
|
|
|
|
You should consider using a third-party component that can do this for you, since such components implement advanced print styles and output formats. These are relatively inexpensive most times and will probably cost you less to buy than what would be required to develop a component even close to what you'd buy. Most are also royalty free.
If you want to do this yourself, then you need to read the documentation[^] for the PrintDocument class and all linked topics. A good object-oriented design would be to extend PrintDocument with your own class, define a property that accepts, for example, a DataTable , then override OnPrintPage to enumerate each row and print the data using the PrintPageEventArgs passed to the method. A very basic example follows:
public class DataPrintDocument : PrintDocument
{
DataTable table;
Font font;
int rowsPerPage = 0;
int margin = 4;
DataRow currentRow;
public DataPrintDocument() : this(null)
{
}
public DataPrintDocument(DataTable table)
{
this.table = table;
font = new Font("Arial", 10f);
}
public Font Font
{
get { return font; }
set { font = value; }
}
protected override void OnPrintPage(PrintPageEventArgs e)
{
base.OnPrintPage(e);
Graphics g = e.Graphics;
if (rowsPerPage == 0)
{
SizeF fontSize = g.MeasureString("CAPS", font);
rowsPerPage = e.MarginBounds.Height - (fontSize.Height + margin);
}
if (table == null || table.Rows.Count == 0)
g.DrawString("No data to print.", font, Brushes.Black, e.MarginBounds.Location);
else
{
int row = 0;
foreach (currentRow in table.Rows)
{
if (row++ > rowsPerPage) break;
}
}
}
} This should be enough to get you started, but I highl recommend a third-party solution that will save you lots of development time and at a relatively low cost. Some of those third-party component houses even advertise here on CodeProject, like ActiveReports from Data Dynamics that I see while typing this reply!
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi,
I am new to C#.
I am writing a file manipulation application and I need to know the extended file properties - those that you can see in Win XP when you right click on column header in detailed explorer view: duration, bit rate, dimension, etc.
What do I need to use in C# to get those values?
Thanks,
lil dracula
|
|
|
|
|
This is not functionality easily exposed to .NET, since it's implementation is done in COM. There are "shortcuts" to doing it that may meet your requirements. See http://www.codeproject.com/csharp/ShellID3TagReader.asp[^] for an example. This is a crude way of doing it, however, since you're relying on data provided by the shell that is specific to folders and prone to breaking if new column providers are added.
The best way is to not rely on column providers and instead read the data yourself using the OLE storage functions (which you'll have to P/Invoke) and IPropertySetStorage and IPropertyStorage interfaces. You should be familiar with COM and COM interop with .NET. Read Interoperating with UnmanagedCode[^] if not, then read about Structured Storage[^] in the Platform SDK, especially about the two COM interfaces I mentioned above.
Different file types are handled by different persistence handlers that provide a way to get properties about the file based on what file it is. The default provider stores the extended information - on NTFS only - in an alternate data stream. For Office documents, this information is stored in the documents themselves and the persistence handler for those file types knows how to extract is and expose it in the same way as others. For supported media files, ID3 tag information or other metadata is extracted by other persistence handlers. This is the only sure way - short of knowing how to read extended information from all the different file types yourself, which would be very difficult (especially with proprietary formats) - of getting extended file information.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thanks for that great info!
It is terrific that there are people like you that helps out the community!
|
|
|
|
|