 |
 |
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
Hi All,
I am looking for expert advice on printing the pdf files at client machine.
I have created a sample project named ClientPrint as
Imports System.Drawing
Imports System.Drawing.Printing
Imports System.Runtime.InteropServices
Namespace ActiveX
Public Interface IActiveXPrintLib
Sub PrintFile(filePath As String)
End Interface
<ProgId("ActiveX.PrintFile")>
<ClassInterface(ClassInterfaceType.AutoDual)>
<ComVisible(True)>
Public Class ActiveXPrintLib
Implements IActiveXPrintLib
<ComVisible(True)>
Public Sub PrintFile(filePath As String) Implements IActiveXPrintLib.PrintFile
Dim AcroPdf As New AcroPDFLib.AcroPDF()
AcroPdf.LoadFile(filePath)
AcroPdf.printAll()
End Sub
End Class
End Namespace
I have created the dll and register the dll using regasm command on client machine.
Now at time of consuming the print method at client side using javascript as
<object id="myControl1" name="myControl1" classid="clsid:ActiveX.ActiveXPrintLib"> </object>
var axComponent = new ActiveXObject("ActiveX.ActiveXPrintLib");
alert(axComponent);
if (axComponent == null) {
alert('Probably not installed');
}
else {
yourAxComponent.PrintFile('<%= Page.ResolveUrl("~/PdfTemp/0d818b57-9384-4f52-ae89-8ef5868064b7.pdf") %>');
alert('yes');
}
I am getting the error that automation server can't create object, using IE I have enabled the active x and permisssions to download the activex. but it still gives me same error.
I am not sure whether my code is correct or not.
Any advice is really helpful.
Thanks in advance.
|
|
|
|
|
 |
Why we need Attribute in .net application ? Please give any real time example.
Thanks in Advance
|
|
|
|
 |
Attributes allow us to decorate something, e.g. a class, with something that indicates to a piece of calling code that this particular thing has certain behaviour. While the operation can appear magical at times, e.g. how does marking a class as Serializable mean it can be serialized, there is always a piece of code at the other side that is checking to see if the attribute exists and acting on it if it's present. Serialization is a great example of the practical use of attributes. As well as marking a class as being capable of serialization, we can use additional attributes to say that certain types in that class should not be serialized. Then, when you attempt to serialize the class in your code, the underlying serialization engine determines that the class can be serialized but it has to ignore certain members in it.
|
|
|
|
 |
What else you suggest ? Whats problem with Attribute ?
|
|
|
|
 |
Hi
i have created DataGrid and i need to align the specific column (4th column i.e index 3) to Center in C# programmatically.
I tried as below
dg1.Columns[3].ItemStyle.HorizontalAlign = HorizontalAlign.Center;
but giving error as follows
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
even if i give index 0 also same error
How to achieve this. If anybody knows reply me.
Thanks in advance.
|
|
|
|
 |
ven753 wrote: even if i give index 0 also same error
That means that your columns have not yet been created at that point.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
 |
No i have dataset and i am adding datasource to datagrid and binding as follows.
dg1.DataSource = ds1.Tables["tblanni"].DefaultView;
dg1.DataBind();
in ds1 4 columns is there and after binding to datagrid same column i will get in datagrid.
Then how to achieve this. Please reply me.
|
|
|
|
 |
Change the alignment AFTER binding - the datageridview does not have the columns at the point where you are accessing them. If it did, the index would not be out of range.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
 |
I added after binding then also its giving same error.
dg1.DataSource = ds1.Tables["tblanni"].DefaultView;
dg1.DataBind();
dg1.Columns[3].ItemStyle.HorizontalAlign = HorizontalAlign.Center;
What to do. Please reply me.
|
|
|
|
 |
Is this a WinForms datagrid (prolly not), an ASP.NET grid or a WPF-grid? In WinForms, life is simple;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
class Test
{
public string Item1 { get; set; }
public string Item2 { get; set; }
public string Item3 { get; set; }
}
DataGridView grid;
public Form1()
{
List<Test> data = new List<Test>();
data.Add(new Test() { Item1 = "bla", Item2 = "foos", Item3 = "bar" });
InitializeComponent();
grid = new DataGridView() { Dock = DockStyle.Fill };
grid.DataSource = data;
Controls.Add(grid);
MessageBox.Show(string.Format("There are {0} columns in this grid", grid.Columns.Count));
}
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
grid.Columns[0].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
}
}
}
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
 |
No i am creating in windows service application. There i am using datagrid
through service cs file i am creating dataset
DataGrid dg1 = new DataGrid();
dg1.ItemStyle.HorizontalAlign = HorizontalAlign.Center; this will work for all the column items and align will become center.
but i need to do for particular column
not working
dg1.Columns[3].ItemStyle.HorizontalAlign = HorizontalAlign.Center;
How to achieve this and it is nor datagridview only DataGrid.
Please reply me.
|
|
|
|
 |
You're creating a UI element inside a Windows Service? Why? A service has no UI, so what are you trying to accomplish here?
|
|
|
|
 |
We can use dataset and result is coming and displaying 4 columns.
Only i need to do particular column alignment.
But its not working.
|
|
|
|
 |
You haven't answered my question. Why are you trying to do this inside a service? A service should have no user interface.
|
|
|
|
 |
Ummm, you've got a HUGE problem. Windows Services cannot display a UI. Starting with Windows Vista, services that attempt to display a UI only show their interface on a separate desktop from the user that's logged in. The user gets a notification that a service has put up a UI window and asked if they want to switch desktops to see it.
UI restrictions on services have now gotten to the point where a service cannot show a UI at all. This "transition" period comes from the days on Windows XP where a service could show a UI. This is a security risk so Microsoft has removed the ability to do this from Windows.
|
|
|
|
 |
I have a string array which will be different but I always need to create a CreateTextTableCell based on AppSettings("RosterFields") fileds count. If no string is found in ArrayHeader create an empty cell up to Settings("RosterFields"). My code below is not working what I have missed?
Dim ArrayHeader() As String = {"1","2"}
For columnIndex = 0 To ConfigurationManager.AppSettings("RosterFields") - 1
For Each value As String In ArrayHeader
CreateTextTableCell(Row, columnIndex, value.ToString, currentRow, 182, True)
Next
Next
|
|
|
|
 |
byka wrote: what I have missed? Point 9:9.Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum. I've posted an answer in the VB.NET forum.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
 |
I need to retrieve the .NET 4.0 install path from a batch file. Following is my batch file code snippet: REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP" /s|FIND "InstallPath"|FIND "4.0."||ECHO The result is InstallPath REG_SZ C:\Windows\Microsoft.NET\Framework64\v4.0.30319\ However, I need to assign the path to a variable. I found some related post online but can’t get any of them work. Any advice is greatly appreciated! Cheers!
|
|
|
|
 |
Why are you using a .bat file? You can extract this information direct from the registry via the RegistryKey Class[^].
|
|
|
|
 |
I know using C# I can do almost anything. However, QA have been using batch files for long time. They know nothing about .NET programming. I am helping to add new features to the batch file, not making technical change at this point. Thanks!
|
|
|
|
 |
Then your statement "However, I need to assign the path to a variable.", needs more detail about what this has to do with the .NET framework.
|
|
|
|
 |
The bottom line is I need to run ngen.exe from the batch file. So I need to know the exact path which is different on a 32bit or 64 bit machine, and .NET 4 with directly minor versions.
|
|
|
|
 |