|
how to add columns to datagrid? sorry i am new to this..
|
|
|
|
|
DGV.columns.Add("ID","ID");
DGV.columns.Add("Name","Name");
DGV.columns.Add("Note","Note");
EASY COME EASY GO
|
|
|
|
|
I am using the dbml file for database tables in the project .
My query is should i manually dispose these unmanaged objects whereever i use this class ?
|
|
|
|
|
What unmanaged objects are you talking about?
/ravi
|
|
|
|
|
I have an webbrowser control on my form. I am able display html files in that control. But my page contains some images if i give absolute path to it then images are displayed. But if i give relative path then images are not shown in the pages.
<br>I have HtmlPages folder located at bin folder.
<br>And i am assigning
FileStream source = new FileStream(@"..\HtmlPages\supportHtml.html", FileMode.Open, FileAccess.Read);
webBrowser.DocumentStream = source;
If i assign D:\myapp\bin\HtmlPages\file.png then there is no problem.
My images are stored in same folder. If i open html files with webbrowser then images are displayed.
What is the correct path to set ??
|
|
|
|
|
You're expecting that the application would load it's images from the same directory where your HTML-files are, as that's the way that it would work in a webserver.
I think that the application is looking in it's own "current directory", which is probably where the executable itself is located. My guess is that it will find the images if you put them there.
I are Troll
|
|
|
|
|
Hi,
by using webBrowser.DocumentStream = source; you are passing data to the WebBrowser without telling it where the data came from, so it cannot possibly use that location as its file base. Why don't you try webBrowser.Navigate(@"..\HtmlPages\supportHtml.html");
|
|
|
|
|
Hi,
I would like to modify the below xml where AssetClass name="CDS" and fieldType id= SECURITY. The below code is throwing exception at root.ReplaceChild... line "The node to be removed is not a child of this node.". Please correct it.. Thanks in advance.
<?xml version="1.0" encoding="windows-1251" ?>
<MSGTaggingConfig version="1.0">
<AssetClassConfiguration>
<GlobalTypes>
<FieldType id="F_TICKER" name="Ticker/Alias" color="#FF6600" type="S" output="false" description="Ticker Description" />
<FieldType id="F_COUPON" name="Coupan/Alias" color="#FF3300" type="S" output="false" description="Ticker Description" />
<FieldType id="F_BID" name="Bid Price" color="#FF9900" type="S" output="false" description="Bid Price Description" />
<FieldType id="F_ASK" name="Ask Price" color="#FFCC00" type="S" output="false" description="Ask Price Description" />
<FieldType id="F_TRENOR" name="Trenor" color="#FFCC33" type="S" output="false" description="Trenor Description" />
<FieldType id="F_MATURITY" name="Maturity" color="#FFCC66" type="S" output="false" description="Maturity Description" />
<FieldType id="F_ASSETQUALIFIER" name="Asset Qualifier" color="#CC9933" type="S" output="false" description="Asset Qualifier Description" />
</GlobalTypes>
<AssetClass id="AC_CDS" name="CDS" description="CDS Asset Class Description">
<FieldType id="SECURITY" name="Security" color="#CC9900" type="C" output="true" description="Security Description" />
<FieldType id="F_New" name="New Name" color="#008040" type="S" output="True" description="New Desc" />
<FieldType id="F_New" name="New Name" color="Green" type="S" output="True" description="New desc" />
<FieldType id="F_New" name="New Name" color="#80FF00" type="S" output="True" description="New Description" />
</AssetClass>
</AssetClassConfiguration>
</MSGTaggingConfig>
string filePath = Application.StartupPath + "\\MSGTaggingBackUp.xml";
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(filePath);
string xpath = string.Format("/MSGTaggingConfig/AssetClassConfiguration/AssetClass");
XmlNodeList fieldNodes = xmlDoc.SelectNodes(xpath);
XmlNode studentNode = null;
XmlNode refNode = null;
foreach (XmlNode node in fieldNodes)
{
if (node.Attributes["name"].Value == "CDS")
{
for (int i = 0; i < node.ChildNodes.Count; i++)
{
if (node.ChildNodes[i].Attributes["id"].Value.ToString() == "Security")
{
studentNode = node.ChildNode[i]; break;
}
}
}
if (studentNode != null)
break;
}
XmlElement root = xmlDoc.DocumentElement;
XmlElement newCd = xmlDoc.CreateElement("FieldType");
newCd.SetAttribute("id", drChangedNode["id"].ToString());
newCd.SetAttribute("name", drChangedNode["name"].ToString());
newCd.SetAttribute("color", drChangedNode["color"].ToString());
newCd.SetAttribute("type", drChangedNode["type"].ToString());
newCd.SetAttribute("output", drChangedNode["output"].ToString());
newCd.SetAttribute("description", drChangedNode["description"].ToString());
root.ReplaceChild(newCd, studentNode);
xmlDoc.Save(filePath);
|
|
|
|
|
Brad North wrote: root.ReplaceChild(newCd, studentNode);
root has no child studentNode .
You must use the parent node from your foreach loop
|
|
|
|
|
I tried this way. Is this the way, you want me to do? I'm facing the same exception
foreach (XmlNode node in fieldNodes)
{
if (node.Attributes["name"].Value == cmbAssetClass.Text)
{
for (int i = 0; i < node.ChildNodes.Count; i++)
{
if (node.ChildNodes[i].Attributes["id"].Value.ToString().ToUpper() == drChangedNode["id"].ToString().ToUpper())
{
studentNode = node;
break;
}
}
}
if (studentNode != null)
break;
}
|
|
|
|
|
foreach (XmlNode node in fieldNodes)
{
if (node.Attributes["name"].Value == "CDS")
{
for (int i = 0; i < node.ChildNodes.Count; i++)
{
if (node.ChildNodes[i].Attributes["id"].Value.ToString() == "Security")
{
studentNode = node.ChildNode[i];
<big> refNode = node;</big>
break;
}
}
}
if (studentNode != null)
break;
}
XmlElement root = xmlDoc.DocumentElement;
XmlElement newCd = xmlDoc.CreateElement("FieldType");
newCd.SetAttribute("id", drChangedNode["id"].ToString());
newCd.SetAttribute("name", drChangedNode["name"].ToString());
newCd.SetAttribute("color", drChangedNode["color"].ToString());
newCd.SetAttribute("type", drChangedNode["type"].ToString());
newCd.SetAttribute("output", drChangedNode["output"].ToString());
newCd.SetAttribute("description", drChangedNode["description"].ToString());
<big> refNode.ReplaceChild(newCd, studentNode);</big>
xmlDoc.Save(filePath);
Didn't try it, should work
|
|
|
|
|
|
Hello Friends
How can I know if value of any entity in a ObservableCollection<t> was changed or updated?
Thanking in Advance
Johnny
|
|
|
|
|
Hello,
I have developed an application in c#, i have also done reporting in it. My application contains folder Reports with .rpt files in it. Currently i m giving the report file path as the full system directory path, i want to give the path directly by using my application boundary,not the complete path. how can i fetch the .rpt file path from the Reports folder, Plz help...
|
|
|
|
|
try using Application.ExecutablePath and strip off the .exe file.
For example:
get the full name of the directory containing your .rpt file.
string strExeName = Application.ExecutablePath;
FileInfo fleExeFileInfo = new FileInfo(strExeName);
string strExeDirName = fleExeFileInfo.DirectoryName;
then get the parent directory of the .rpt by using...
string strParentDir = fleExeFileInfo.Directory.Parent.FullName;
hope this helps....
|
|
|
|
|
It worked, thanks alot
|
|
|
|
|
By any chance are you not aware of Application.StartupPath ?? Then yo don't have to do all these string manipulations..
|
|
|
|
|
hi
I want to make grouping in the data grid view. like
Table 1
pk col1 col2
1 ABC 51
2 DEF 74
-----------------------
Table 2
pk col1 col2 col2 col3 fk(pk_table_1)
1 abc 3 23 111 1
2 def 3 45 74 1
3 kki 8 23 871 2
4 qwe 2 15 5 2
5 eed 7 41 91 2
------------------------------------------
Now I want to show the data in the grid but in summarized form. like only the data that is in table 1 will be displayed first and at the left most a + sign will be displayed when we press that the data of table 2 will be displayed then.
Thanks
Syed Shahid Hussain
|
|
|
|
|
Syed Shahid Hussain wrote: Thanks
There's no question in this post, that makes it somewhat harder to formulate an answer.
AFAIK, the requested behaviour isn't standard available in the DataGridView. It might be best to look for a 3d-party grid that supports drill-down and grouping.
I are Troll
|
|
|
|
|
I have written the simple code as below:
Addede reference (C:\Program Files\Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office11\Microsoft.Office.Interop.Excel.dll)
private void button1_Click(object sender, EventArgs e)
{
Microsoft.Office.Interop.Excel.Application _objAppln;
Microsoft.Office.Interop.Excel.Workbook _objWorkBook=null ;
_objAppln = new Microsoft.Office.Interop.Excel.Application(); // To initialize excel file
if (_objAppln != null)
{
_objWorkBook = _objAppln.Workbooks.Add(Type.Missing); // To add workbook with sheets in excel file
//_objWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet)_objWorkBook.ActiveSheet; // To get the current active sheet in excel file
}
string _fileName = "temp.xls";
_objWorkBook.SaveAs(_fileName,
Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookNormal, Type.Missing, Type.Missing, false, Type.Missing, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
_objWorkBook.Close(true, _fileName, false);
_objAppln.Quit();
_objWorkBook = null;
_objAppln = null;
}
After the code is execuled, the instance of Excel (EXCEL.exe) is seen in taskbar. I have as many number of instances, as many times I click on the button.
The instance exists even when I stop the application.
What is wrong in the above code.
Gurpreet
|
|
|
|
|
Hi
I had the same problem
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
GC.WaitForPendingFinalizers();
after setting _objAppln=null; worked for me
greets
|
|
|
|
|
Explicitly calling GC.collect is not recommended. Is there any other good way to handle it?
Gurpreet
|
|
|
|
|
Try releasing the Excel Application COM object by using the following code:
try
{
if (objAppln!= null)
System.Runtime.InteropServices.Marshal.ReleaseComObject(objAppln);
}
catch (Exception)
{
}
finally
{
objAppln = null;
}
|
|
|
|
|
KaurGurpreet wrote: What is wrong in the above code.
I'm missing the code to close the workbook and exit the Excell application.
Meh, they're there, just overlooked them.
This kb-article[^] might help. The only other alternative[^] that I can offer;
Marshal.ReleaseComObject(workBook);
I are Troll
|
|
|
|
|
Hi,
To compare two datarows, I used Equals method as shown below. But it returns false, though the rows are equal.
dtGridOld.Rows[i].Equals(dtGridNew.Rows[i])
Please let me know the correct way. Thanks in advance
|
|
|
|