|
UI elements must be accessed on only the GUI thread. The Control class provides the Invoke /BeginInvoke methods to do this. See here[^] for a reference.
|
|
|
|
|
The 'solution' that was given first worked for me. Again my problem was only there when I was debugging in Visual Studio. Running the code in the normal way didn't pose any problems. So it seems to be only a VS issue!!
I will read the article that you described and see if something in the code has to be changed. Although I doubt that since I make use of delegates and that should take care of the thread issues.
Thanks for the feedback.
Regards,
Jan
|
|
|
|
|
jkpieters wrote: since I make use of delegates and that should take care of the thread issues.
Only if properly written using some form of Invoke. They are not a "guaranteed" solution to the problem.
jkpieters wrote: So it seems to be only a VS issue!!
No, it's not. If you enable the "CrossThreadCheck" property, you are not fixing the problem, nor all causes of it. You are mearly hiding the problem in certain situations.
|
|
|
|
|
It really doesn't matter if it's in or out of VS when it's running, if an app is throwing invalid cross-thread operation exceptions then it's not observing the "One GUI Thread" rule. The only reliable way to do so is to use the IvokeRequired/Invoke/BeginInvoke members of the Control class.
|
|
|
|
|
Ya you are right the solution is not advisable. I agree with you, but in this case as it was mentioned as a VS only problems during debugging that's why I have told him to do this. This will atleast allow your code to debug in VS. That's what he needed only.
But still it is not a good practice. Using of delegates is the good way to do it.
|
|
|
|
|
Hi,
I am trying to display 2 tables content in 2 DataGridViews on a single form. So i used 2 SQLDataAdaptor objects (for each table) and only 1 DataSet in which i selected both the tables during configuring. I wrote the following code:
sqlDataAdapter1.Fill(dataSet11);
sqlDataAdapter2.Fill(dataSet11);
dataGridView1.DataMember = "authors";
dataGridView2.DataMember = "publishers";
This code doesn't work. On running no data is displayed on the datagrids. If i set DataMember in DataGridView properties at design time then it works fine, but programmatically if i set, it does not work.
Please help me out!
Regards,
Priya.
|
|
|
|
|
try to set them manually after add COLs to each
EASY COME EASY GO
|
|
|
|
|
manually when i set in DataGridView DataMember property at design time it is working fine, but programatically it is not. Why is that?
|
|
|
|
|
sorry maybe i was not clear my self try this:
after you fill the dataset with database you can get each row with:
<code>
foreach(DataRow dr in DS.Tables[0].Rows)
{
DGV.Rows.Add(dr[0],dr[1],dr[2],dr[3]...);
}
</code>
but first you should add COLs
EASY COME EASY GO
|
|
|
|
|
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
|
|
|
|