|
I don't think everybody is furious. The tone would be far nastier if they were. What you have to understand, though, is that your original statement was far too vague, and far too broad. We don't know what technology (other than C#) you are using, and we don't know what you've done so far - it's up to you to help us help you.
Have you got any code in place at all?
|
|
|
|
|
In that case, you're screwed! Nobody is going to do your homework for you. If you didn't make the time to do your own work, why should we do it for you??
|
|
|
|
|
read this[^]
fafal wrote: and i have not enough time
What makes you think we do?
Try it out for yourself first. You can get directions here if you're stuck (follow guidelines in the link), but nobody's going to give you code or do your homework for you.
V.
|
|
|
|
|
ok tnx
|
|
|
|
|
You're welcome. And seriously, if you do run into problems, return here (with the rules in mind) and you'll certainly get response.
V.
|
|
|
|
|
|
Are you thinking out loud?
|
|
|
|
|
You're half right.
|
|
|
|
|
Hey,
Im trying to insert cross reference into a word document, the document itself is consists of 2 headings:
1.1.1 SUBJECT1
1.1.2 SUBJECT2
while trying to iterate through all the subjects with GetCrossReferenceItems(ref oRefType); function I do get both of the subjects, however, when I use the InsertCrossReference function, it always inserts the last subject into the document (meaning, I get duplicate SUBJECT2 cross references)
See below simplified example:
object file = @"c:\somefile.docx";
object oRefHyperlink = true;
object oRefType = WdReferenceType.wdRefTypeHeading;
object arr_r = doc.GetCrossReferenceItems(ref oRefType);
Array arr = ((Array)(arr_r));
Microsoft.Office.Interop.Word.Application document = new Microsoft.Office.Interop.Word.Application();
Document doc = document.Documents.Open(ref file, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj);
object oRefItem = arr.GetValue(arr.Length);
doc.Application.Selection.InsertCrossReference(ref oRefType, WdReferenceKind.wdContentText, ref oRefItem, ref oRefHyperlink, ref InsertPosition, ref SeperateNumbers, ref nullobj);
oRefItem = arr.GetValue(1);
doc.Application.Selection.InsertCrossReference(ref oRefType, WdReferenceKind.wdContentText, ref oRefItem, ref oRefHyperlink, ref InsertPosition, ref SeperateNumbers, ref nullobj);
has anyone came crossed into this problem?
Thank you for your response.
|
|
|
|
|
Before when I used the vb.net I faced the similar problem. Then I remember instead of using the Cross Reference, I used the Paragraphs.And then I found a solution to my problem...
In richTextBox you can append the text easily, and save as document file....
|
|
|
|
|
Unfortunately there are alot of actions I need to do over the document , in fact, the entire application is based on word document so I can't do these actions over the rich text box
can you please expand alittle about the Paragraphs thingy ? how did you do it ?
|
|
|
|
|
Shine..actually its vb.net2008 code..I don't have time to convert to c#..so you need to convert it.
Dim OPara1 As Microsoft.Office.Interop.Word.Paragraph
Dim Rng As Microsoft.Office.Interop.Word.Range = WrdDcmt.Paragraphs(1).Range
OPara1 = WrdDcmt.Paragraphs.Add
OPara1.Format.SpaceBefore = 50
OPara1.Range.Text = "REFERENCE No. : AMC/" + Dprt + "/" + DvPoint + "/MPR-" + TextBox1.Text + vbCrLf
OPara1.Range.Text = "DATE : " + QtRqt
OPara1.Format.SpaceAfter = 6
OPara1.Range.InsertParagraphAfter()
For RichTextBox
RichTextBox4.AppendText("DATE : " + QtRqt)
RichTextBox4.AppendText(" " + vbCrLf)
RichTextBox4.AppendText("To" + vbCrLf)
RichTextBox4.AppendText("Some of Your Text" + vbCrLf)
// Simply you can copy the rtb Text and can Paste to your Range and can add to your document..
RichTextBox4.SelectAll()
RichTextBox4.Copy()
Rng.Paste()
I hope this can helps a bit for your search
|
|
|
|
|
First of all thank alot for your help
As far as i can see you enter the Cross Reference programmatically, am I right ?
can you please help me understand this line ?
OPara1.Range.Text = "REFERENCE No. : AMC/" + Dprt + "/" + DvPoint + "/MPR-" + TextBox1.Text + vbCrLf
thank you
|
|
|
|
|
Those are strings - DPRT & DvPoint
|
|
|
|
|
So I still don't understand how the Cross reference is being made :[]
you don't use the InsertCrossReference Function over here
|
|
|
|
|
you don't actually seem to be inserting the value at position 0. Taking a look at your assignments to oRefItem , you actually start at the length of the array (which would be after the end of the array). Surely you want to assign it here as arr.GetValue(0);
|
|
|
|
|
Hey Pete,
The array holds values from index 1 to n, index 0 throws out of range exception
|
|
|
|
|
How on earth has this been created? Standard indexing in C# is zero-based.
|
|
|
|
|
The
object arr_r = doc.GetCrossReferenceItems(ref oRefType); return non-zero indexed array (string[*]) which forces the programmer to cast a non-zero array.
|
|
|
|
|
OK, try this:
object file = @"c:\somefile.docx";
object oRefHyperlink = true;
object oRefType = WdReferenceType.wdRefTypeHeading;
object arr_r = doc.GetCrossReferenceItems(ref oRefType);
Array arr = ((Array)(arr_r));
Microsoft.Office.Interop.Word.Application document = new Microsoft.Office.Interop.Word.Application();
Document doc = document.Documents.Open(ref file, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj);
int i = arr.Length;
while (i > 0)
{
object oRefItem = arr.GetValue(i--);
doc.Application.Selection.InsertCrossReference(ref oRefType, WdReferenceKind.wdContentText, ref oRefItem, ref oRefHyperlink, ref InsertPosition, ref SeperateNumbers, ref nullobj);
}
|
|
|
|
|
Thanks for your message,
unfortunately it didn't help, the problem isn't with getting the problem value from
oRefItem I think there is a certain bug in
InsertCrossReference function...
E.G: when I have 2 subjects over the document (1.1.1 SUBJECT1, 1.1.2 SUBJECT2) and I try to get ONLY the last subject, I keep getting the cross reference for the first subject.
|
|
|
|
|
What do you see in the values when you step over them in the debugger?
|
|
|
|
|
the array holds the correct values.
arr.GetValue(1)- Subject1
arr.GetValue(2) - Subject2
|
|
|
|
|
Hi,
Iam using C# 2010. I would like to know, is it possible to select a column name of listview?
I mean, once the user click on second column, then I want to get the second column value...also, once the user click on third column then the reslutant has to be thisd column value...
Is it possible?
Iam using the following codes...for listview...
for (int F12 = 0; F12 <= MyDataTable.Length - 1; F12++)
{
ListViewItem GItem = new ListViewItem(MyDataTable[F12]["invoic_no"].ToString());
GItem.SubItems.Add(MyDataTable[F12]["invoice_date"].ToString());
GItem.SubItems.Add(MyDataTable[F12]["Supplier_name"].ToString());
GItem.SubItems.Add(MyDataTable[F12]["itm_description"].ToString());
GItem.SubItems.Add(MyDataTable[F12]["unit_measure"].ToString());
GItem.SubItems.Add(MyDataTable[F12]["Invoice_Quantity"].ToString());
listView1.Items.Add(GItem);
}
listView1.Visible = true;
listView1.Focus();
Note: ListView1.SelectedItems[0].text or
ListView1.SelectedItems[0].SubItems[1].text all will give the value by assigned column.
But My clarification is is it possible to get the unkwon clicked column name...
Thanks
|
|
|
|
|
Using the ListView.HitTest[^] method; you give it the coordinates where the user clicked, and it'll return which subitem the user clicked on.
Bastard Programmer from Hell
|
|
|
|