|
Thanks a lot, it was missing "Test,"
|
|
|
|
|
Hi,
I have a couple of headings that need set to bold and underlined but having trouble getting this to work in itextsharp. Writing out to a pdf. I can get the heading set to bold or i can get it underlined but not both at the same time.
Font normalBold = FontFactory.GetFont("times", 10, Font.BOLD);
Font normalBoldUnderlined = FontFactory.GetFont("times",10,Font.UNDERLINE);
I have also tried to create a paragraph but include the heading and set it to underlined but for some reason it sets the whole document underlined..
Paragraph paragraphThree = new Paragraph("Exchanger Represents:\n", normalBold);
paragraphThree.SetAlignment("Justify");
paragraphThree.IndentationLeft = 20;
paragraphThree.Font.SetStyle(iTextSharp.text.Font.UNDERLINE);
Anyone any ideas apart from drawing a line as to how to do this?
Thanks in advance
Paul
|
|
|
|
|
Are those flags combinable (i.e. Font.BOLD | Font.UNDERLINE)?
|
|
|
|
|
Excellent BobJanova. That works perfectly.
Thanks for your answer
Paul
|
|
|
|
|
Welcome. This is a common pattern in .Net for combinations of options, for example control styles, anchoring, keyboard modifiers and as you found out font options.
|
|
|
|
|
I'll keep that in mind. Thought i was going nuts as I couldn't find an example anywhere on the net and I knew it would be something simple
Thanks again
|
|
|
|
|
A lot of hints to be found here[^].
Luc Pattyn [My Articles] Nil Volentibus Arduum
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Please use <PRE> tags for code snippets, they improve readability. CP Vanity has been updated to V2.3
modified on Friday, June 10, 2011 8:40 PM
|
|
|
|
|
|
Below there is code for update button the error for this code is mentioned in subject line.
private void update_Click(object sender, EventArgs e)
{
try
{
con.Open();
OleDbDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
if (securityname.SelectedItem.ToString() == dr[0].ToString())
{
break;
}
}
cmd.Parameters.AddWithValue("@User_Id", OleDbType.VarChar);
cmd.Parameters.AddWithValue("@Security_Name", OleDbType.VarChar);
cmd.Parameters.AddWithValue("@qty_bought", OleDbType.Integer);
cmd.Parameters.AddWithValue("@qty_sold", OleDbType.Integer);
cmd.Parameters.AddWithValue("@Rate_Security", OleDbType.Double);
cmd.Parameters.AddWithValue("@Total_security", OleDbType.Double);
cmd.Parameters.AddWithValue("@Brokerage", OleDbType.Double);
cmd.Parameters.AddWithValue("@Net_Rate", OleDbType.Double);
cmd.Parameters.AddWithValue("@Service_Tax", OleDbType.Double);
cmd.Parameters.AddWithValue("@Stt_Amt", OleDbType.Double);
cmd.Parameters.AddWithValue("@Total_Amt", OleDbType.Double);
cmd.Parameters.AddWithValue("@Net_Delivery", OleDbType.Double);
cmd.Parameters.AddWithValue("@Tran_Charges", OleDbType.Double);
cmd.Parameters.AddWithValue("@Sec_Tran_Charges", OleDbType.Double);
cmd.Parameters.AddWithValue("@Stamp_Duty", OleDbType.Double);
cmd.Parameters.AddWithValue("@Total_due", OleDbType.Double);
cmd.Parameters.AddWithValue("@NSE", OleDbType.Boolean);
cmd.CommandText = "Update Security SET qty_bought=@qty_bought,qty_sold=@qty_sold,Rate_Security=@Rate_Security,Total_Security=@Total_Security,Brokerage=@Brokerage,Net_Rate=@Net_Rate,Service_Tax=@Service_Tax,Stt_Amt=@Stt_Amt,Total_Amt=@Total_Amt,Net_Delivery=@Net_Delivery,Tran_Charges=@Tran_Charges,Sec_Tran_Charges=@Sec_Tran_Charges,Stamp_Duty=@Stamp_Duty,Total_due=@Total_due,NSE=@NSE Where Security_Name=@Security_Name AND User_Id=@User_Id";
securityTableAdapter.Update(strUserId, Convert.ToInt32(Qty_biught.Text), Convert.ToInt32(qty_sold.Text), Convert.ToDouble(gross_rate.Text), Convert.ToDouble(tot.Text), Convert.ToDouble(broker.Text), Convert.ToDouble(Net_rate.Text), Convert.ToDouble(Serv_Tax.Text), Convert.ToDouble(stt_amt.Text), dTot, Convert.ToDouble (Net_Del.Text), Convert.ToDouble(Tran_chr.Text), Convert.ToDouble(Sec_tran_tax.Text), Convert.ToDouble(stamp_duty.Text), Convert.ToDouble(bal_amt.Text), NSE.Checked, dr[0].ToString(), dr[1].ToString(), Convert.ToInt32(dr[2].ToString()), Convert.ToInt32(dr[3].ToString()), Convert.ToDouble(dr[4].ToString()), Convert.ToDouble(dr[5].ToString()), Convert.ToDouble(dr[6].ToString()), Convert.ToDouble(dr[7].ToString()), Convert.ToDouble(dr[8].ToString()), Convert.ToDouble(dr[9].ToString()), Convert.ToDouble(dr[10].ToString()), Convert.ToDouble(dr[11].ToString()), Convert.ToDouble(dr[12].ToString()), Convert.ToDouble(dr[13].ToString()), Convert.ToDouble(dr[14].ToString()), Convert.ToDouble(dr[15].ToString()), Convert.ToBoolean(dr[16].ToString()));
dr.Close();
cmd.ExecuteNonQuery();
Security_name.Text = securityname.Text;
securityname.Visible = false;
Security_name.Visible = true;
con.Close(); }
catch (Exception ex)
{
con.Close();
MessageBox.Show(ex.ToString());
}
}
Bold code is having a exception and I made all initialization regarding Connection and Command in Load_Form().
modified on Thursday, June 9, 2011 12:31 AM
|
|
|
|
|
Hi,
I'm not familiar with that exception.
I'm having difficulties reading your code, as you did not use PRE tags. You could still edit and add them.
I did see a few strange things:
1.
there are two very similar lines cmd.ExecuteReader(); and cmd.ExecuteNonQuery();
2.
the declarations and initialisations of con and cmd are missing.
3.
The normal way to do database accesses would be:
- to have an open,use,close pattern for the connection, relying on connection pooling. A using statement is extremely useful here, as it would close the connection for you.
- to have a create, use, dispose pattern for the command, again a using statement works well.
4.
The DataReader also needs being disposed of; again using is useful.
So it would end up looking like this:
using (OleDbConnection con=new OleDbConnection(...)) {
using (OleDbCommand cmd=new OleDbCommand(...)) {
using (OleDbDataReader dr = cmd.ExecuteReader()) {
while (dr.Read()) {
...
}
}
}
using (OleDbCommand cmd=new OleDbCommand(...)) {
cmd.Parameters.Add...;
cmd.ExecuteNonQuery();
{
}
Now con, cmd, dr automatically get closed/disposed even when exceptions were thrown.
PS: I have no idea what "AutoSizeMode" is doing in your subject line.
Luc Pattyn [My Articles] Nil Volentibus Arduum
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Please use <PRE> tags for code snippets, they improve readability. CP Vanity has been updated to V2.3
|
|
|
|
|
Hello.
I'm implementing WebDAV COPY method.
public void Copy(string userName, string password, string source, string destination)
{
CredentialCache MyCredentialCache = new CredentialCache();
MyCredentialCache.Add(new System.Uri(source), "Basic", new NetworkCredential(userName, password));
try
{
HttpWebRequest Request = (System.Net.HttpWebRequest)HttpWebRequest.Create(source);
Request.Credentials = MyCredentialCache;
Request.Method = "COPY";
Request.Headers.Add("Destination", destination);
Request.Headers.Add("Overwrite", "F");
HttpWebResponse Response = (System.Net.HttpWebResponse)Request.GetResponse();
Response.Close();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
The method works fine with non-unicode file names.
But, if I want to copy a file with korean letters in its name (http://myDAVserver.myCompany.com/dav/한글.txt) I get the following error:
Message: Specified value has invalid Control characters.
Parameter name: value
I tracked the error, and the exception is being throwed exactly in
Request.Headers.Add("Destination", destination);
Does anybody have an idea how to handle this problem?
Thank you.
|
|
|
|
|
The problem could be a conflict between the character sets allowed in URIs and filenames (on whatever system). I had a quick peek at the RFCs but the allowed character set for URIs didn't leap out at me. (The destination parameter is specified by the WebDAV RFC as being a URI.) Perhaps the documentation of HttpWebRequest specifies what character set it will allow in headers - it should, if it throws an exception when you get it wrong.
Not a solution on a plate, but hopefully this will point you in the right direction.
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
HTTP headers have to be 7 bit ASCII, I think, nominally. They are certainly interpreted at best as 8 bit ANSI (Windows western encoding). You will need to encode the Unicode characters.
|
|
|
|
|
Thank you for the answer.
Yes. You are right.
I could have encoded the Unicode characters and URL using HttpUtility.UrlEncode Method.
But the problem is, it is implemented only in .Net 4.0, but unfortunately, I'm writing my program in .Net 3.5 do to the compatibility with "a little bit old OSs" with older versions of .Net.
Still did not find a proper solution.
That was totally wrong.
I tried to use HttpUtility.UrlPathEncode(str) method directly without adding reference to the System.Web Namespace in project's properties:
...
using System.Web;
...
string convertedPath=HttpUtility.UrlPathEncode(path);
...
And after adding reference, I did like this:
...
string convertedPath=System.Web.HttpUtility.UrlPathEncode(path);
...
and it worked.
Thank you guys!
|
|
|
|
|
I am trying to execute a delegate from Method B1 for ButtonC and I get the following error:
Object reference not set to an instance of an object.
Have I setup the delegate correctly, what am I doing wrong.
I appreciate any help.
Thanks in advance,
Michael
namespace Z
{
public delegate void DelC(object sender, EventArgs e);
static partial class A
{
public static void Main()
{
FormC FC = new FormC();
DelC delC = new DelC (FC.buttonC_Click);
}
}
public static class B
{
public static DelC delC = null;
public static void B1()
{
object sender = new object();
EventArgs e = new EventArgs();
delC(sender, e); *****ERROR - Object reference not set to an instance of an object.
}
}
public class FormC
{
public void buttonC_Click(object sender, EventArgs e)
{
SortData();
}
}
}
modified on Tuesday, June 7, 2011 10:11 PM
|
|
|
|
|
In your static class B , delC is set to null and never set to an instance of B.DelC as the error message indicates.
Sort of OT: Why all the static classes? It seems you may be learning and confused by instances and trying to work around it by using static. Bad idea IMO!
If this is just a test code sample then fine, but otherwise; the System.EventHandler delegate that is used everywhere has the same signature so I would use that instead.
[Edit] When posting code, please place the code inside <pre></pre> tags. There is a widget available when posting that says "code block" that will help with this. Your code will then be much easier to read, therefore easier for us to help you!
|
|
|
|
|
The 1st class is static because it is my entry into the program
The 2nd class is static because it is constant used class, so I made it static if it should not please explain.
The 3rd class is actually a form and in reality is not a static class, I edited to read public.
You said to use "System.EventHandler" is that in place of a delegate, can you give me an example.
Thanks,
Michael
|
|
|
|
|
Yeah, what he said. Plus, you define DelC in both classes, that means that they are different delegates and will cause trouble. As with interfaces, when you declare a delegate, it's best to do so outside of any class.
|
|
|
|
|
I took out the 2nd reference to the DelC in the example and still have the same problem.
I can not set an instance of the delegate as follows:
FormC FC = new FormC();
DelC delC = new DelC(FC.buttonC_Click);
in class B because the project with Class B is downstream from the project Class FormC that is why I placed the above in Main and the reason I am using a delegate.
Thanks,
Michael
modified on Tuesday, June 7, 2011 10:09 PM
|
|
|
|
|
You haven't attached a handler for the event.
MAW30 wrote: Class B is downstream
Whatever that means.
How about this... in A...
DelC delC = new DelC (FC.buttonC_Click);
B.delC = new DelC (FC.buttonC_Click);
Once you instantiate B.
But it's a bad design.
modified on Tuesday, June 7, 2011 11:42 PM
|
|
|
|
|
When I said it was downstream I meant as far as references to projects.
I can't reference the project for class B, it will give a circular reference.
Thanks,
Michael
|
|
|
|
|
Then rethink the whole mess.
|
|
|
|
|
How can I get the title of this window and ensure it has certain specific text in it, to separate it from other notepad windows like it in C sharp? I have a program I'm trying to send controls to and the controls differ depending on the title and text of the window. I was using a DLL add on that will not function correctly in win7 because of the different way some GUI windows are drawn, so I wanted to make the entire app .net native.
Thanks for reading.
http://img683.imageshack.us/img683/3281/testgui1.jpg
|
|
|
|
|
There is no standard way to read window titles and text. Every platform (by this, I mean, C++/MFC, Winforms, WPF, etc) stores the title differently. Sometimes applications will store titles themselves if they are owner / custom drawing. As for getting the window text, thats equally impossible. Every control stores it differently. What about item based controls like ListView?
If all you care about is notepad.exe SPECIFICALLY, you can call Win32 GetWindowText() through interop on the window as well as the text box control inside to get it consistently across OSes.
|
|
|
|
|
Thanks for the response.
Notepad (as you guessed) was an example, I would like to be able to do this with any program I decide to build or interact with. Specifically this time, the program I am building now will interact with HP OpenView ticketing system. I believe it is written in Java? (an poorly written at that) and is obnoxious to try and interact with.
|
|
|
|
|