|
Do you have the XSL file? If so, use System.Xml.Xsl.XslCompiledTransform. But it will give you HTML, not DOC.
|
|
|
|
|
I don't have xsl file actually.
So I search the web and found a file that xml convert to MS Word 97-2003
It's work fine, but not for word 2007.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
|
|
Hello,
I want to find the location of HTMLControls (button, radiobutton, etc)On web page. I have used webbrowser control in my application. when the web page is displayed on the controls, i just need the exact location of particular htmlControl. how can i find it.
Thanks in advance.
The source code of my application program is :
if (webBrowser1.Document != null)
{
HtmlElementCollection elemColl = null;
HtmlDocument doc = webBrowser1.Document;
elemColl = doc.All;
foreach (HtmlElement e1 in elemColl)
{
if (e1.GetAttribute("Name") != "")
{
string location = e1.OffsetRectangle.Location.ToString();
}
}
but above code gives me the relative position. i want exact location of htmlControls on web page.
|
|
|
|
|
I am reading data from XML like Column Name and Visiblity of column i.e. CheckBox.
And want to Write in DataGridView. DGV having Column name and Visiblity as column.
|
|
|
|
|
If I am understanding your question correctly, then:
You can get the xml data into the datset using DataSet.ReadXML method and set it as the source for the grid.
|
|
|
|
|
Hi all,
I've use a foreach loop to remove some elements from a list. Actually I want to remove selected elements. Here is my attempt.
foreach (int i in View1.SelectedIndices)
{
View1.Items.RemoveAt(i);
}
View1 is my list and it correctly get all selected elements correctly. But when remove elements are removing in odd order. I mean, say I selected 5 elements. My code remove 1st 3rd and 5th elements. Not the 2nd and 4th. Any solution. Is that my foreach loop is incorrect.
Thanks.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
This can't work. Think about it for a minute.
Here are your items:
1
2
3
4
5
Select them all. Now, first iteration, your collection is
2
3
4
5
and now it removes the item at position 2. Because that's the position that was next in the list. So, you get
3
4
5
and so on. Any operation like that, you need to work in descending order, so that the changing order does not break your outcome.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Can you please tell me how can I do it in my code.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
I would imagine if you can get a collection of selected items, and then find the index of each item so you delete that, that will solve your issue. I'd make a copy of it first too, because removing items can cause the selections to be lost, I believe.
The other way is to take the collection of selected indices, and sort if in reverse order, I believe there's sort functions built in for that. You could iterate over such a collection easy enough. Or you could even make a copy and pull indices from the tail end instead of using for each which starts at the front
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Thanks sir,
I'll first going to try with the deletion from reverse order as you said. Basically removing the foreach loop. If I'm fail with try to use a duplicate list and work on. I don't like much to use it, because it can use much memory.
I'll let you know what happened.
Thanks.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
The typical solution can be like
for(int selectedItemIndex = View1.SelectedIndices.Count; selectedItemIndex >= 0; selectedItemIndex--)
{
View1.Items.RemoveAt(View1.SelectedIndices[selectedItemIndex]);
}
|
|
|
|
|
Close
Maybe it should be
int selectedItemIndex = View1.SelectedIndices.Count - 1
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
yeah,
the code will be fixed after IndexOutOfRangeException had been occured.
|
|
|
|
|
A simple while loop will do it.
while (listBox1.SelectedItems.Count != 0)
{
listBox1.Items.Remove(listBox1.SelectedItems[0]);
}
|
|
|
|
|
No, my way is FAR better.... :P
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Christian Graus wrote: No, my way is FAR better
Might be. But, when I checked your replies, it included more steps
|
|
|
|
|
I thought we don't have FAR in 32-bit operating systems.
|
|
|
|
|
In vb I have a class from the OM that I set as a global variable - gMT = new OM.clsMasterTables. This holds the tables in memory for all the static table data, for use in combos and lists etc. If a user modifies a master table the form removes the table from the object (gMT.TableName = nothing) and next time it is used it is refreshed from the database.
I would like to achieve this in C#. I am having a problem scoping the instantiation of the gMT object. This is my startup class, the enum is avaialble but gMT is not
static class clsMain<br />
{<br />
[STAThread]<br />
static void Main()<br />
{<br />
Application.EnableVisualStyles();<br />
Application.SetCompatibleTextRenderingDefault(false);<br />
<br />
CSDUserOM.Credentials oCreds = new CSDUserOM.Credentials();<br />
oCreds.Server = "localhost";<br />
oCreds.Database = CSDUserUI.Properties.Settings.Default.Database;<br />
oCreds.UserID = CSDUserUI.Properties.Settings.Default.UserID;<br />
oCreds.Password = CSDUserUI.Properties.Settings.Default.Password;<br />
oCreds.Integrated = true;<br />
CSDUserOM.clsMain.SetCredentials(oCreds);<br />
<br />
<br />
Application.Run(new frmMain());<br />
}<br />
<br />
public static CSDUserOM.clsMasterTables gMT = new CSDUserOM.clsMasterTables();<br />
public enum enSecurity<br />
eUser }<br />
}
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
You may want to put the gMT in frmMain rather than clsMain.
|
|
|
|
|
Hey, I was wondering if anyone can help me with trimming a string array. I am calling an API that returns this (At bottom of post).
I am then using this to convert that into a string array
string[] apiresult = new string[25];
char[] splitter = { ';' };
apiresult = result.Split(splitter);
My question is, how do I trim the string array so it just contains
success<br />
1<br />
Bob<br />
etc...
instead of
result=success<br />
userid=1<br />
firstname=Bob<br />
etc...
result=success;userid=1;firstname=Bob;lastname=Smith;companyname=Smith Enterprises;email=bsmith@boostplatform.com;address1=1 Smith Drive;address2=;city=Bobtown;state=Bobstate;postcode=12345;country=US;phonenumber=419-123-4567;notes=TESTING ACCOUNT!!;password=bsmith;status=Active;credit=1010.00;taxexempt=;language=;lastlogin=No Login Logged;billingcid=0;domainemails=;generalemails=;invoiceemails=;productemails=;supportemails=;
|
|
|
|
|
you need to take each string and split it on the =. So, this is a two step thing. you need to iterate over the one set and split each string to get the second set.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Othr than CG suggested, you can try this also
string[] apiresult = result.Split(';', '=');
List<string> expectedList = new List<string>(apiresult.Length / 2);
for (int i = 1; i < apiresult.Length; i = i +2)
{
expectedList.Add(apiresult[i]);
}
Splitting is done in single step here.
|
|
|
|
|
Thanks, but I don't want the firstname, lastname, etc... part of the array. Just the actual answers (Bob, Smith, etc...)
|
|
|
|