|
Is there a way to identify how many items does the first column have?
I can see that the P, Q, R values are for the second column, how would you know where to start splitting?
superselector wrote:
Col1 Col2
A P
B Q
C R
D
|
|
|
|
|
The number of items may vary in a culumn.. but one thing is consistent that values will be seperated by comma,its just a sample i have given for understanding of the question. also the number of columns in first datatable is dynamic. it will change based on certain condition but irrespective of the number of columns i want to replicate this datatable and display those comma separated values in a row. The final datatable should have as many rows as the highest lenght of the splitted value
|
|
|
|
|
OK, maybe I was not clear, lets have this example:
DataTable 1:
Column1, Column2, Column3
DataTable 2:
Value1, Value2, Value3, Value4, Value5, Value6, Value7, Value8
The final result for you should be like below?
Column1, Column2, Column3
Value1, Value2, Value3
Value4, Value5, Value6
Value7, Value8
if the above representation is OK, its quite simple, you just have to:
1. Add to the new DataTable the content of the first DataTable
2. Add a new row to the new DataTable, start to add the values
3. When you reached the length of the first DataTable (or first row of the current DataTable) you need to start a new row.
|
|
|
|
|
Thanks , I was able to get it working.
|
|
|
|
|
Ok, if I am understanding correctly, I would approach it like this.
Loop through each column
Convert the data from that column to a 'table' - I do this with some SSRS reports. There are a lot of links about doing this example 1, example 2.
I would try putting each into it's own table then combining them in the end, but it seems like there should be an easier way.
|
|
|
|
|
I am Making Application in visual studio 2010 in windows form using C#
I want to get scan images from scanner.
How can i do???
Please help
Thank You
Sanket
|
|
|
|
|
A quick search found this[^] article here on CodeProject.
|
|
|
|
|
Hi! I trying to use DataContractSerializer to save objects with crossreference. It´s two lists of objects.
I doesn´t get a error but even though the file is created it does´t work to get it back.
Maybe it´s better to use BinaryFormatter?
Some of my code:
DataContractSerializer xs = new DataContractSerializer(typeof(List<Customer>));
DataContractSerializer xs2 = new DataContractSerializer(typeof(List<Book>));
Book-class:
[KnownType(typeof(FaktaBok))]
[KnownType(typeof(BarnBok))]
[KnownType(typeof(SportBok))]
[DataContractAttribute()]
public class Book
{
[DataMember]
protected int isbn = 0;
[DataMember]
protected string titel = null;
[DataMember]
protected string author;
[DataMember]
protected int price;
[DataMember]
protected String isType = null;
[DataMember]
protected Kund biblioteksKund = null;
One derived class:
[DataContractAttribute()]
public class SportBok : Bok
{
[DataMember]
private string sport;
Serialize:
using (Stream s = File.Create(path))
{
xs.WriteObject(s, CustomerList);
}
using (Stream s2 = File.Create(path2))
{
xs2.WriteObject(s2, BookList);
}
DeSerialize:
if (File.Exists(path))
{
using (Stream s = File.OpenRead(path))
{
CustomerList = (List<Kund>)xs.ReadObject(s);
}
}
if (File.Exists(path2))
{
using (Stream s2 = File.OpenRead(path2))
{
BookList = (List<Bok>)xs2.ReadObject(s2);
}
}
|
|
|
|
|
I have done some modification for your code -
[KnownType(typeof (FaktaBok))]
[KnownType(typeof (BarnBok))]
[KnownType(typeof (SportBok))]
[DataContractAttribute()]
public class Book
{
[DataMember]
public int IsBn = 0;
[DataMember]
public string Titel = null;
[DataMember]
public string Author;
[DataMember]
public int Price;
[DataMember]
public String IsType = null;
}
public void SerializerTestMethod()
{
List<Book> books = new List<Book>
{
new Book()
{
Author = "author1",
IsBn = 1,
IsType = "istype1",
Price = 10,
Titel = "booktitle1"
},
new Book()
{
Author = "author2",
IsBn = 2,
IsType = "istype2",
Price = 20,
Titel = "booktitle2"
}
};
string writeTo = @"FilePath";
DataContractSerializer xs2 = new DataContractSerializer(typeof (List<Book>));
using (Stream s2 = File.Create(writeTo))
{
xs2.WriteObject(s2, books);
}
List<Book> outBook = null;
if (File.Exists(writeTo))
{
using (Stream s2 = File.OpenRead(writeTo))
{
outBook = (List<Book>) xs2.ReadObject(s2);
}
}
} }
}
|
|
|
|
|
Well, the reason I didn´t even get an error was because the Form_Load didn´t fire.
But now that I fixed that I get "unable to serilalize" due to elements not being closed or something like that.
The application is a library and customers can lend books.
What I do is save a list of books in a customer objekt so you know what books the customer borrowed.
What exactly is your code doing?
|
|
|
|
|
As per the subject, problem using DataContractSerializer, I have updated your contract with public properties. And the DataContract is getting serialized.
|
|
|
|
|
The only thing I can see you have changed is that you made the SerializerTestMethod.
Did you change anything else?
|
|
|
|
|
When using DataContract it is advisible to use Public properties instead of protected.
That is my other change ... Following is the serialized datacontract with sample data.
<ArrayOfBook xmlns="http://schemas.datacontract.org/2004/07/TestSampApp" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Book>
<Author>author1</Author>
<IsBn>1</IsBn>
<IsType>istype1</IsType>
<Price>10</Price>
<Titel>booktitle1</Titel>
</Book>
<Book>
<Author>author2</Author>
<IsBn>2</IsBn>
<IsType>istype2</IsType>
<Price>20</Price>
<Titel>booktitle2</Titel>
</Book>
</ArrayOfBook>
|
|
|
|
|
|
Hi guys,
I have the above error, it errors on the first line of my code:
HtmlDocument doc = (HtmlDocument)Enquiry_Sourcing_Netcomponents.Document;
doc.GetElementById("Session_Username").SetAttribute("value", "XXXXX");
doc.GetElementById("Session_Password").SetAttribute("value", "XXXXX");
doc.GetElementById("").InvokeMember("click");
HtmlElementCollection theElementCollection = doc.GetElementsByTagName("input");
HtmlElementCollection elems = doc.GetElementsByTagName("input");
foreach (HtmlElement elem in theElementCollection)
{
String nameStr = elem.GetAttribute("name");
if (nameStr != null && nameStr.Length != 0)
{
String contentStr = elem.GetAttribute("content");
System.Windows.MessageBox.Show("Document: " + Enquiry_Sourcing_Netcomponents.ToString() + "\nDescription: " + contentStr);
}
}
Any ideas?
|
|
|
|
|
Member 8811089 wrote: Any ideas? Yes, you cannot cast an object type to a dissimilar one - it does not work. So whatever class Enquiry_Sourcing_Netcomponents.Document is (mshtml.HTMLDocumentClass ), it is not the same as a System.Windows.Forms.HtmlDocument type.
Veni, vidi, abiit domum
|
|
|
|
|
What exactly is "Enquiry_Sourcing_Netcomponents.Document" ?
Why do you think it is convertible to Type HtmlDocument ?
Is HtmlDocument in this case the same thing as mshtml.HTMLDocument ?
Google CEO, Erich Schmidt: "I keep asking for a product called Serendipity. This product would have access to everything ever written or recorded, know everything the user ever worked on and saved to his or her personal hard drive, and know a whole lot about the user's tastes, friends and predilections." 2004, USA Today interview
|
|
|
|
|
Enquiry_Sourcing_Netcomponents is the name of the browser control in the project
|
|
|
|
|
You are probably using the "Microsoft Web Browser" control added to the toolbox from the "COM" tab when selecting Toolbox items.
Use the "WebBrowser" control from the toolbox located under the "All Windows Forms" node in the toolbox.
|
|
|
|
|
Hi TnTinMn,
I suggest you move your thoughtful reply to the top-level of this thread; I think you might have given the OP the answer to their problem; perhaps, since your reply has been inserted as a reply "underneath" my response, the OP might miss it.
bill
Google CEO, Erich Schmidt: "I keep asking for a product called Serendipity. This product would have access to everything ever written or recorded, know everything the user ever worked on and saved to his or her personal hard drive, and know a whole lot about the user's tastes, friends and predilections." 2004, USA Today interview
|
|
|
|
|
Bill,
As I replied to the OP's reply to your question, I think he/she/whatever should have been notified.
Whether or not my suggestion is the solution, I have a strong feeling that that knowledge will be like the old Tootsie Pop commercial -- "the world may never know."
Thanks for the concern.
|
|
|
|
|
Hi all,
I have a probably simple question:
I like to make a simple PGN player program with a (sizeable) chessboard UI. I have already programmed a PGN parser to parse besides moves and tags also comments and recurcive notation/variations.
My questions are:
1. What 'simple' chessboard interface (UI) is capable of accepting moves in standard PGN format to replay a game
2. I do not need a chess engine, it is purely for replaying of games
3. I use C# as programming language and have found several examples of programs that either have not the UI that I can use or they can't import complex PGN files
4. I also need to be able to use the program without Internet
I know of the existence of Winboard (which is C++) but it seems as overkill for my needs.
I have had a look at Sharpchess, SrcChess and PGNViewer for now.
Do you have any suggestions where to start?
Thanks in advance,
Francis
|
|
|
|
|
You could start with Chess Program in C#[^] for ideas.
However, request you not to plagurise this article.
|
|
|
|
|
i write this code :
when i debuged , in line 5 i see this error : "Exception of type 'System.OutOfMemoryException' was thrown."
do u know what should i do?
1- HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWriter);
2- DataGrid DataGrd = new DataGrid();
3- DataGrd.DataSource = dsGrid;
4- DataGrd.DataBind();
5- DataGrd.RenderControl(htmlWrite);
|
|
|
|
|