I am adding list inside pdfcell.But the identation of this list is not coming properly.
its coming like this:
• One
• Two
• Three
But the same list if add directly to the document,the identation is coming properly.Like below:
• One
• Two
• Three
here is the code :
list = new List(false, 14.4F);
list.ListSymbol = new Chunk("\u2022", FontFactory.GetFont(FontFactory.HELVETICA, 10,iTextSharp.text.Font.BOLD));
ListItem listItem;
listItem = new ListItem(lstrBullets.Trim(), FontFactory.GetFont(FontFactory.HELVETICA, 10, iTextSharp.text.Font.NORMAL));
list.IndentationLeft = lftBulletIndent;
listItem.SetLeading(10.0F, 1.0F);
listItem.Alignment = Element.ALIGN_JUSTIFIED;
list.Add(listItem);
PdfCell cell = new PdfCell();
cell.AddElement(list);
pobjTable.AddCell(cell);
where lftBulletIndent gives the indentation values for list.Please help what i am missing here.How can i retain the indentaion inside a cell?
This how I solved this. I know this is not a proper one.But it worked for me.
I am adding a table with variable width in the first cell of the parent table i.e here pobjTable
PdfPTable DummyTable = new PdfPTable(2);
//Here the floatSpace value changes according to the lftBulletIndent values
float[] headerwidths = { 2f + floatSpace, 98f - floatSpace};
DummyTable.SetWidths(headerwidths);
Pcell = new PdfPCell();
Pcell.Border = Rectangle.NO_BORDER;
DummyTable.AddCell(Pcell);
Pcell = new PdfPCell();
Pcell.AddElement(list);
Pcell.Border = Rectangle.NO_BORDER;
DummyTable.AddCell(Pcell);
pobjTable.AddCell(DummyTable);//Inserting a new table here
pobjTable.AddCell("");
Related
I'm trying to make two-level grid control. It has some package with its elements. I want to add one more column to gridView3 and hide three columns. I'm sending data to this gridView in code (dataset - 2 tables with one relation).
I've tried to send data to this gridcontrol and then operate on gridviews
gridControl2.DataSource = value.Tables[0];
gridView3.PopulateColumns(value.Tables[1]);
gridView3.Columns["RpkeId"].Visible = false;
gridView3.Columns["SourceLueId"].Visible = false;
gridView3.Columns["NewLueId"].Visible = false;
and then I'm trying to add column:
var test = new List<int> { 1, 12, 123, 1234 };
RepositoryItemComboBox riComboBox = new RepositoryItemComboBox();
riComboBox.Items.AddRange(test);
gridControl2.RepositoryItems.Add(riComboBox);
GridColumn columnGIDNumer = new GridColumn();
columnGIDNumer.FieldName = "asdfasdfa";
columnGIDNumer.ColumnEdit = riComboBox;
columnGIDNumer.OptionsColumn.AllowEdit = true;
gridView3.Columns.Add(columnGIDNumer);
None of these seem to work:
Is there any event I need to invoke or something? It seems that it'd work in normal, one-level gridcontrol.
Thanks in advance!
I have:
List<string> dates1 = new List<string>();
List<string> values1 = new List<string>();
List<string> dates2 = new List<string>();
List<string> values2 = new List<string>();
That will accept my data ranges from a datasource. Dates1 and Values1 have 128 values in each list.
The dates1 data looks like this {"5/29/2015 11:02",....,"5/30/2015 11:02",....,"5/31/2015 11:02",....,"6/1/2015 11:02",....,"6/2/2015 11:02",....,"6/3/2015 11:02"} with the in between data points being different times within that day for a total 128 values.
The dates2 data looks like this {"5/29/2015 9:05","5/30/2015 9:05","5/31/2015 9:05","6/1/2015 9:05","6/2/2015 9:05","6/3/2015 9:05"} with 7 total values.
The two graphs separately look correct and like this:
The problem is getting both graphs on the same chart correctly.
If I create 2 series on the chart I will get this:
I have seen some advice to use Chart1.AlignDataPointsByAxisLabel(); and this is what I get:
The two graph should be spread out evenly over each other but the x-axis for the 2nd series is being disrupted for some reason. Is this even possible to do? I would greatly appreciate any help you can spare.
Here is the c# code if interested:
List<string> dates = new List<string>();
List<string> values = new List<string>();
List<string> dates2 = new List<string>();
List<string> values2 = new List<string>();
//*****SQL connection and code that populates the Lists is here*****
Chart1.Series.Add(new Series());
Chart1.Series[0].Points.DataBindXY(dates, values);
Chart1.Series[0].ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.StepLine;
Chart1.Series[0].Color = Color.Red;
Chart1.Series[0].BorderWidth = 1;
Chart1.Series[0].ToolTip = "#VALY, #VALX";
//BIND THE DATA TO THE CHART
Chart1.Series.Add(new Series());
Chart1.Series[1].Points.DataBindXY(dates2, values2);
Chart1.Series[1].ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.StepLine;
Chart1.Series[1].Color = Color.Green;
Chart1.Series[1].BorderWidth = 2;
Chart1.Series[1].ToolTip = "#VALY, #VALX";
//SET THE IMAGE OUTPUT TYPE TO BE JPEG
Chart1.ImageType = System.Web.UI.DataVisualization.Charting.ChartImageType.Jpeg;
//ADD A PLACE HOLDER CHART AREA TO THE CHART
Chart1.ChartAreas.Add(new ChartArea());
Chart1.AlignDataPointsByAxisLabel(); // THIS IS THE COMBINING OF AXES
Chart1.ChartAreas[0].Area3DStyle.Enable3D = false;
Chart1.ChartAreas[0].AxisX.MajorGrid.LineColor = Color.FromArgb(50, 200, 200, 200);
Chart1.ChartAreas[0].AxisY.MajorGrid.LineColor = Color.FromArgb(50, 200, 200, 200);
//ADD A PLACE HOLDER LEGEND TO THE CHART
//SHOW THE LEGEND
Chart1.Legends.Add(new Legend());
Chart1.Legends[0].Enabled = true;
Edit: having dates, in the 2nd dataset, that match up perfectly to dates in the first seems to fix it. The issue is the dates will never match because they are taken at different times and has a time precision. Surely, there is a way to do this that I'm missing.
You can achieve your requirement using Syncfusion chart by setting columnIndex property for each axis. columnIndex is used to split the chart horizontally so that we can place series without overlapping.
Following Screenshots illustrate this
We have prepared a sample based on your requirements. Please find the sample from below link.
Sample Link:
http://jsfiddle.net/jr8x19vz/55/
Syncfusion also offers ASP.NET wrappers powered by Essential Studio for Javascript, providing client-side rendering of HTML 5-Javascript controls. You can get more information about Syncfusion’s ASP.Net suite from the following location,
http://www.syncfusion.com/products/aspnet
You can view the demos from the following link,
http://js.syncfusion.com/demos/web
Also take a look at our community license which provides free access to our entire products,
http://www.syncfusion.com/products/communitylicense
Please let me know, if you have any changes.
Thanks,
Jayavigneshwaran
I finally figure it out. One issue I had was pulling in my date as a string instead of DateTime. I switched to DateTime and it fixed the issue while using a data table and binding with Chart1.DataBindCrossTable.
var dt = new System.Data.DataTable();
dt.Columns.Add("Series", typeof(string));
dt.Columns.Add("Date", typeof(DateTime));
dt.Columns.Add("Value", typeof(string));
//looping through SQL datasource for first series
while(){
dt.Rows.Add("Today", date, value);
}
//looping through SQL datasource for second series
while(){
dt.Rows.Add("Yesterday", date, value);
}
Chart1.Series.Clear();
Chart1.DataBindCrossTable(dt.Rows, "Series", "Date", "Value", "");
I am using iTextsharp (version 4.1.6 - an LGPL fork) to generate a PDF that contains simply a table. My project is a .net 4 application.
The table can have lots of columns and lots of rows and the PDF will not contain anything else (so I want to use landscape layout on an A4 page).
I, therefore, knocked up this (I cut it down to the code that interacts with iTextSharp, you can guess what the columns, data, val and ms variables are):
// Create a landscape A4 page...
var doc = new Document(new Rectangle(297, 210), 10, 10, 10, 10);
PdfWriter.GetInstance(doc, ms);
doc.Open();
var table = new PdfPTable(columns.Count()) {HeaderRows = 1};
var titleFont = FontFactory.GetFont(BaseFont.COURIER_BOLD, 10);
var bodyFont = FontFactory.GetFont(BaseFont.COURIER, 10);
// Add the column headings...
foreach (var c in columns)
{
var cell = new PdfPCell(new Phrase(c.Title, titleFont))
{
NoWrap = true
};
table.AddCell(cell);
}
// Add the data...
foreach (var o in data)
{
foreach (var c in columns)
{
var cell = new PdfPCell(new Phrase(val, bodyFont))
{
NoWrap = true
};
table.AddCell(cell);
}
}
doc.Add(table);
doc.Close();
Lovely except that creates a 1 page document where all the cells are overlapping and is completely unreadable.
What I want to achieve is something that looks like this:
So the columns never overlap, they just expand out onto the next page and the column headings are repeated as the rows extend down.
I've tried fiddling with KeepTogether etc but I am flummoxed as to how to achieve this result.
i want to create series dynamically for that i created series array objects like this
Series[] series = new Series[10];
series[0].Name = "Result Chart";
but while execution of program it showing object reference null error
how to solve this problem
Series[] series = new Series[10];
series[0] = new Series();// this line is the one you missed
series[0].Name = "Result Chart";
Series[] series = new Series[10];
This line create an array. The new is just for creating array of series.
This line puts the value at the 0th index
series[0].Name = "Result Chart";
The problem is that you have not instantiated the object at 0th index.
So you need to instantiated every index which you want to use.
Like if you want to use the 0th index then you will have to use
series[0] = new Series();
or just create a loop to instantiated every index as follows
for(int i=0;i<series.Count;i++)
{
series[i] = new Series();
}
string title = HardwareInfo.GetComputerName().ToString();
TabPage myTabPage = new TabPage(title);
// tabControl1.TabPages.Add(myTabPage);
// Create Column Headers
ListView listView2 = new ListView();
ColumnHeader columnA = new ColumnHeader();
columnA.Text = "adsasd";
columnA.Width = 185;
columnA.TextAlign = HorizontalAlignment.Left;
ColumnHeader columnB = new ColumnHeader();
columnB.Text = "asd";
columnB.Width = 185;
columnB.TextAlign = HorizontalAlignment.Left;
ColumnHeader columnC = new ColumnHeader();
columnC.Text = "asdasd";
columnC.Width = 185;
columnC.TextAlign = HorizontalAlignment.Left;
ColumnHeader columnD = new ColumnHeader();
columnD.Text = "xx";
columnD.Width = 185;
columnD.TextAlign = HorizontalAlignment.Left;
// Add columns to the ListView:
listView2.Columns.Add(columnA);
listView2.Columns.Add(columnB);
listView2.Columns.Add(columnC);
listView2.Columns.Add(columnD);
listView2.Size = new Size(800, 300);
listView2.Location = new Point(0, 0);
listView2.GridLines = true;
listView2.View = View.Details;
Here I have a copy of some of my Code, and what I am looking to do is get a list of computers on my next work, then create tabs for each computer. I have that part done perfectly fine, but the issue I am having is that, it creates the listviews with the same NAME and that is causing an obvious problem when I try and add information to those specific list views. I was wondering, how would I go about giving each listview a name of the computer for example. As you can see for my tabs I can do that, but when it comes to the list views, if i try and do the same type of assign a string title to where it says Listview listview2 It wont let me compile. I'm new to programming and I apologize if this is obvious. Thank you.
It sounds like you want to create a List<ListView> and add your listviews to it.
Depending on how you use it, you may want a dictionary instead.
If i understand the question what you want is the name variable, in this case
listView2.name = <name of listview2>
http://msdn.microsoft.com/en-us/library/system.windows.forms.listview_members(v=vs.71)
But i think you should look into using functions with a returntype of columns for those column constructor parts.
You want the to make the variable that stores the listview part of a dictionary, this way you can look up the different computers by their name, or whatever string you desire
Dictionary<string, ListView>
http://msdn.microsoft.com/en-us/library/xfhwa508.aspx
You could use a List if you don't need the lookup portion of the dictionary, but is fine with using integers as with an array
List<ListView>
http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx