|
I assume you already tried using the "this" keyword like I said above? If that doesn't work, you can take two approaches. With one approach, try to create the error with a very small tester form. Then, post that here for us to review. Or, try removing code from your project little by little until it starts working.
|
|
|
|
|
I am currently testing it with the 'this' keyword. But why should this approach solve the problem? What are the technicalities behind it?
|
|
|
|
|
Was just a wild guess really. Not sure if it would help.
|
|
|
|
|
Okay, that didn't help Any more ideas?
|
|
|
|
|
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?
|
|
|
|