|
i didnt mean that,, i wanna to know if there any resources of what i need couse i searched but i didnt find any good result, & if u familiar of these kind of problem u know that it is just the first step
thx
SUMA
|
|
|
|
|
Harta hr = this.ParentForm;
hr.OnPaint1();
this code raises the folowing error
Error 1 Cannot implicitly convert type 'System.Windows.Forms.Form' to 'THE_PROJECT.Harta'. An explicit conversion exists (are you missing a cast?) C:\Documents and Settings\Razvan\My Documents\Visual Studio 2005\Projects\THE PROJECT v2\THE PROJECT v2\Elemente.cs 48 23 THE PROJECT v2
i knew it was imposible for that to work but i need to call that method from the child form. Can somebody help me?
rzvme
|
|
|
|
|
Harta hr = this.ParentForm as Harta;<br />
if (hr != null) hr.OnPaint1();
Arthur Dent - "That would explain it. All my life I've had this strange feeling that there's something big and sinister going on in the world."
Slartibartfast - "No. That's perfectly normal paranoia. Everybody in the universe gets that."
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
The method that Pete mentions is valid. However, I would suggest you look at having the child form raise an event that the parent form subscribes to.
public class MainForm : Form<br />
{<br />
public void CreateChild()<br />
{<br />
ChildForm cForm = new ChildForm();<br />
cForm.ParentForm = this;<br />
cForm.MyOnPaint += new EventHandler(OnPaint1);<br />
<br />
cForm.Show(); <br />
}<br />
<br />
protected override void OnPaint1(object sender, EventArgs e)<br />
{<br />
}<br />
}<br />
<br />
public class ChildForm : Form<br />
{<br />
public event EventHandler MyEvent;<br />
<br />
protected override void OnMyEvent(object sender, EventArgs e)<br />
{<br />
if (MyEvent != null)<br />
MyEvent(sender, e);<br />
}<br />
}
Please forgive any typos as I wrote the above code on-the-fly. So, in the child form when something happens that you want to communicate back the event you just call OnMyEvent from within the ChildForm. The nice thing about this is that it promotes loose coupling, because the ChildForm doesn't know if it's parent is MainForm or SomeOtherForm. You can take it a step further by making the event part of an interface that ChildForm implements. In that way you decouple the child from the parent as well.
|
|
|
|
|
How can you find a datareader is open or closed ?
|
|
|
|
|
Have you checked IsClosed()?
|
|
|
|
|
Hi..
This is Vijay..I started learning .NET recently and I have a module in c#.NET, which should call the file(c:\data.txt)which is in binary format and the data should be updated in the database according to the notepad file...Plz someone help me retrieving the data from notepad char by char and differentiating between the delimiter..
Thanks
Vijay Mesa
|
|
|
|
|
Are you trying to read the file in character by character?
|
|
|
|
|
Hi everyone!
Please help me with following questions:
1- How can we add nodes in treeView using following context menu:
Before Node (at same Level)
After Node (at same Level)
Child Node
2- How can we disable particular contextMenuItem? For example if root node is selected "Before Node" will be disable. Where should I put "meuItem.enable = fasle;" line in the code. I have used "treeView_AfterSelect" event for disabling but it doesn't work fine with right click.
Please guide me by an example and please tell me if any sample on code project regarding treeView.
Thank You.
|
|
|
|
|
Go add a new TreeNode at the same level as a given TreeNode you will need to look at the current TreeNode's parent and add your new node to the parents Nodes collection using the Insert method of the TreeNodeCollection.
A rough example (not tested):
.
.
.
int currentIndex = CurrentTreeNode.Parent.Nodes.IndexOf(CurrentTreeNode);
.
.
.
CurrentTreeNode.Parent.Nodes.Insert(NewNode,currentIndex);
.
.
.
CurrentTreeNode.Parent.Nodes.Insert(NewNode,currentIndex+1);
.
.
.
Note that you should check that the current node isn't the root (parent == null).
To add a child you simply add a new node to the current node using CurrentTreeNode.Add(NewNode)
To disable the menu items you might want to do it on the context menus Popup event.
|
|
|
|
|
How can I set the currentTreeNode equal to Selected Node.
I want to add before and after the selected node.
Thank you.
|
|
|
|
|
You need to hook in to the AfterSelect event and then test the value of e.Node.Level to determine what level in the tree control the selected node is located. Based on this value you can enable/disable different menu items. To do this with mouse clicks, you need to hook in to the NodeMouseClick event. You can test using something like e.Node.IsSelected && e.Button == MouseButtons.Right
In your event handlers, you will need to use the value of e.Node to determine which node you need to interact with to add the new TreeNode object.
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
Hi
I can develop a project in multilanguage in C# but i am unable to convert it in VB.net. Any one ready for assistance...................
Regards
Syed Shahid Hussain
|
|
|
|
|
Hi,
I know that to convert an int to a string you use:
myInt.toString();
But, I want to convert a string to int, what is the function for this?
Thanks.
|
|
|
|
|
In .NET 2.0 use Int32.TryParse , otherwise Int32.Parse .
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Thanks mate, a great help
|
|
|
|
|
There is also a method like
Convert(variable,CType)
Good Luck
Syed Shahid Hussain
|
|
|
|
|
Just FYI, there is also a method called Convert.ToInt32(). Either method will work fine.
|
|
|
|
|
I've created a control that has a simple label on it and a progress bar. When a certain event happens i create a new instance of the control and add it to my parent control. Once the event is finnished i dispose of the control.
My problem is that the control is never displayed. I know its being created since i've added trace's and can see that its checking to see if it needs to update the progress bar.
When i call the progress bar, i check to see if it needs to be invoked and then do the below code:
initControl = new InitControl();<br />
this.Controls.Add(initControl);<br />
<br />
int posX = ((this.Width / 2) - (initControl.Width / 2));<br />
int posY = ((this.Height / 2) - (initControl.Height / 2));<br />
initControl.SetBounds(posX, posY, 100, 100);
The question is, What am i missing so the control isnt showed?
|
|
|
|
|
gareth111 wrote: Once the event is finnished i dispose of the control. A control that has been disposed is not going to display.
led mike
|
|
|
|
|
There are mainly 2 to 3 points you need to take care of:
1.) You are adding to this.Controls , so hopefully there should be no other control present at the same Location within this.Controls array.
2.) The InitControl is the topmost control within the this.Controls list.
3.) The InitControl's 'Visible' property is set to TRUE.
Regards,
Vin...
There are two types of fools in this world: One who give advice and the others who do not take it...
|
|
|
|
|
led mike:
I dont dispose of it until im finnished with it, i dont just create it and then dispose of it instantly.
vinSharp:
Its visiability is set to true, but im unsure what you mean by 1 and 2.
|
|
|
|
|
gareth111,
By points 1 and 2 I meant the following:
Suppose you add InitControl at Location (10,10) within the this.Controls
and elsewhere you add another opaque control whose span overlaps the InitControl, then also it would make your control invisible.
To do a double check on that, add the following line after initControl.SetBounds(...)
Add the line: initControl.BringToFront()
Check whether this works for you...
There are two types of fools in this world: One who give advice and the others who do not take it...
|
|
|
|
|
|
i want to integrate a sentinel hardware device with one of my applications that icreated, so i wanted to know if C# is able to check for hardwares that are plugged in on your machine, so i would love for anyone to tell me how to do this or send me a link of what to read up on to do this
kenny edmond
|
|
|
|