|
Show me the exact code that causes the problem. Create as small of a tester application as you can and paste ALL of the code for it (but remember to try and make the example concise). It's probably something simple, but I can't help you unless I see the code you are using.
|
|
|
|
|
I was finally able to fix the problem:
Apparently the handle for the richtextbox did not exist when i tried to invoke it. Since i used it in a background thread, the invokerequired property returned 'false', sometimes causing it to display the illegal cross thread operation exception (suring program startup).
The solution was to use the Form_load event which would signal the background thread when it was fully loaded.
But its still a bit unclear how such a thing can happen. When does actually InitializeComponent return? When can i be sure that the control handles exist?
|
|
|
|
|
Glad to hear you got it working.
InitializeComponent should be called from the constructor. You should only reference controls after that call to InitializeComponent.
|
|
|
|
|
Oh but i did call it from the constructor, then started the background thread and inside that thread tried to access the controls.
|
|
|
|
|
I'm creating a control where I want 3 separate containers(2 sub containers and 1 main container)
So to do that, I simply inherit the Panel control and adding 2 sub Panels in Constructor.
And the problem is, when I drag any item in that control it get added to the Main container...but I want it to be inside the Panel it dragged on.
It suppose to be like TableLayoutPanel
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
You can edit the InitializeComponent() function afterwards manually. Search for a line like
this.Controls.Add(this.controlWhichShouldBeOnPanel2);
and change that to something like
panel2.Controls.Add(this.controlWhichShouldBeOnPanel2);
|
|
|
|
|
Thats not what I want. I want design-time support.
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
The problem is prossibly because the controls were added in the constructor, not via the designer. This means the size and postion of the sub-panels might not be visible in the designer. One method I sometimes use is to temporarily set the background colours of your panels to various (and obviously different) colours, so you can see what is where in the designer. Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter.
Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.
|
|
|
|
|
nope, I can see them clearly
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
I have this xml:
<resume>
<details>
<resumeName>Jassim</resumeName>
</details>
<experience>
<company ID="xxxxxxxxxxxxxxxx">
<name>apple</name>
<title>developer</title>
</company>
<company ID="bbbbbbbbbbbbbbbbb">
<name>microsoft</name>
<title>analyst</title>
</company>
</experience>
</resume>
how can I bind the expreience elemnt into a data grid so I will have ID, company and title columns?
|
|
|
|
|
I would create a new class with your ID, company, and title fields and map each company XML node to an instance of that class. Then bind that collection of class instances to a DataGrid. You can also just load company XML node fields into a DataTable in the same way that OriginalGriff showed you how to load FileInfo objects in response to your other post.
You can use XPath or Linq2XML to get the company nodes from the XML document.
|
|
|
|
|
How can I populate list if files with size and created date into a data table then bind to a dataGrid?
|
|
|
|
|
This uses a DataGridView rather than the web-centric DataGrid, but the principle is the same. (I can't be bothered to load a web site to test it, so you get a DataGridView).
DataTable dt = new DataTable("Directory of " + strPath);
dt.Columns.Add("Name");
dt.Columns.Add("Size");
dt.Columns.Add("CreateDate");
DirectoryInfo di = new DirectoryInfo(strPath);
FileInfo[] files = di.GetFiles();
foreach (FileInfo fi in files)
{
dt.Rows.Add(fi.Name, fi.Length ,fi.CreationTime);
}
dataGridView1.DataSource = dt;
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
I have the following xml:
<resume>
<details>
<resumeName>Jassim</resumeName>
</details>
</resume>
i am using this code to read the resumeName:
string resumeNameValue = doc.GetElementsByTagName("resumeName")[0].InnerText;
is it possible to have it like ["details"] instead of [0] SO i will also refer to it by name instead of id?
|
|
|
|
|
You can use XPath like this:
string resumeNameValue = doc.SelectSingleNode("/resume/details/resumeName").InnerText;
|
|
|
|
|
Hi All,
Can someone help me.
I have made an application (a kind of texteditor) in VS2008. Now will I count the words is the textbox. It works with the splitfunction. But can anyone help me with this becaus I don't want you use the split function.
I am a beginner with C# and I want to learn how the splitfuntion works. I know that is works with the if-else statement. But How???
Kind regards
|
|
|
|
|
kevinwell wrote: learn how the splitfuntion works
Why?
But, yes, I wouldn't split a string just to count the number of words it contains.
|
|
|
|
|
Use a Regex : "\w+" will match each word, you can then just use the match count. You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
You can use the IndexOf method inside a for loop to count all the spaces contained in the string.
Or, you can write a RegEx that matches a word and count the number of matches (EDIT: beaten by OriginalGriff on this one ).
|
|
|
|
|
Mirko1980 wrote: beaten by OriginalGriff on this one
nah, nah, de nah-nah!
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
OriginalGriff wrote: nah, nah, de nah-nah!
and how many words is that? 5 according to Regex? 4 when splitting by white-space? 0 according to Webster?
|
|
|
|
|
|
kevinwell wrote: It works with the splitfunction. But can anyone help me with this becaus I don't want you use the split function.
Smells like homework to me. You only get these kinds of requirements when an instructor hands out assignments.
In any case, since you seem incapable of figuring this out on your own...
Just iterate through each character of the string, and wehenever you encounter a space (or a tab), increment a counter. At the end of the loop, add 1 to the counter, and that's how many words are in your string..45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: At the end of the loop, add 1 to the counter, and that's how many words are in your string.
Unless the string is empty, only whitespace, has multiple whitespace characters in a row (e.g., "\r\n"), or contains leading/trailing whitespace.
|
|
|
|
|
I have a C# 3.5 Windows form application that uses the webbrowser control.
This control is used to navigate through a website, where I have a parsing engine that pulls data off the site and stores it in a file. The customer navigates to the site, presses the "record" button and the parsting starts.
The parser is triggered by the DocumentComplete event. This works very well, but I have seen that this event sometimes does not fire. The customer has to navigate through 500 pages and by the time they get to page 500, we found that we are missing maybe 5-6 of the pages.
We have traced the problem to be that the documentcomplete event is not firing all the time. My debug code indicates that the navigating and havigated events have fired correctly, but not the document complete.
At the end of the 500 page run, I have 500 navigating events, 500 navigated events and a variable number of documentcompelte events, ranging from 490-495. We have not traced it to any single page, but are unable to figure out what is causing this. We even added a sound that beeps when the page loads and have found pages that load in the browser and are viewable, but the sound does not play because the event didn't fire. Any thoughts what might be causing this?
|
|
|
|