|
You can't drag and drop onto a web control. What were you hoping to drag and drop onto it ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks for your reply,well,I'm doing a HTMLEdit control writen by c#,and I want to drag a html tag item into this control,then I paste a tag html into this control.
Sorry for my poor English ,but I really want your help ,thanks
|
|
|
|
|
No need to apologise, I'm glad to help, but a WebBrowser control does not show HTML, it just renders it. And it doesn't support drag n drop.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
If I add WebBrowser control in VB6.0 ,then I could drag items to it and drop,I think Com control to Com control is works ok ,but when add WebBrowser control in .net programe,it doesn't work.
You are right "WebBrowser control does not show HTML",but WebBrowser control has a DOM property,and use mshtml.HTMLDocument Interface ,I can control it's html,what I want to do is draging item into WebBrowser control,and when droped I add some html string into some where by mshtml.HTMLDocument interface.
If some one want simple code,I can send it to your Email adress,my email is cecilia_in_love@163.com .I really want help!
Also sorry for my poor English ,I'm not a English speaking country.
|
|
|
|
|
OK, I didn't know that the browser control had drag and drop at all. It's kind of weird, I mean, if you drag and drop a string, how will you know where in the DOM to put it ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Greetings,
I've successfully implemented MS's control array as prescribed in this article:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchcreatingcontrolarraysinvisualbasicnetvisualcnet.asp
But I would like to implement a two dimensional control array. I'm adding buttons to a series of tab pages, and I need to be able to address the buttons on each tab page.
Is it possible to modify the class provided in the article to support a second dimension? I'm a newbie at C# so I will need a few key lines of code which illustrate the modifications needed. Thanks.
|
|
|
|
|
if you need to access Button in tabPage you dont have to create array as when you add control to tabpage this control will be add to controls collection of tabPage
to access all the button in tabpage you can write somthing like
foreach(Control ctl in tabPage1.Controls)
{
if(ctl is Button)
{
Debug.WriteLine(ctl.Name);
}
}
MCAD
|
|
|
|
|
Hi
I need help as i have a usercontrol loaded at runtime on a main form .What i want to do is on click of a button on usercontrol i want to refresh the treeview control with fresh data on the main form and load other control on the main form. how can i do that.
thanks
monica
|
|
|
|
|
Set up a delegate which you call when the button is pressed, and which the main form ties to a method that refreshes the tree control.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
can u explain a bit more a give me some example site to have a look at it i am new to c#.net
thanks
|
|
|
|
|
Oh, you've made the leap from VB ? Congratulations !!
Here[^] is an online tutorial. Basically, your control contains a definition of an event ( a delegate ) and an instance of that type. It defaults to null, and when the button is pressed, if it's not null, it calls it. The main page sets this variable to be a function IN the main page which matches the definition. In this function, you refresh the tree view. This function is then called by your control whenever the button is pressed.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi Christian
That tutorial is not elping me much. can u give a bit more details. Is it the way
i have declared a public delegate in the main form which i am calling in the click event of the button on usercontrol.
Thanks
monica
|
|
|
|
|
In the control:
public delegate void ClickEvent();
public ClickEvent RefreshTree = null;
inside the click event handler for the button in the control:
if (RefreshTree != null) RefreshTree();
in the mainform:
void RefreshEvent()
{
theTree.Invalidate();
}
inside the create method, just after the call to initialisecomponents:
theControl.RefreshTree = new ControlType.ClickEvent(this.RefreshEvent);
There are a few things that need renaming, but that's basically it. The control defines the event and an instance of it. The main form defines the method and ties it to the event. The control calls the event if it's been set when the button is pressed. The method that is called refreshes the tree.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
sorry to bother you again.
"inside the create method, just after the call to initialisecomponents:
theControl.RefreshTree = new ControlType.ClickEvent(this.RefreshEvent);"
i could not get the concept of this line.
where this line is to be written in the main form or in the control.
if i write this line inthe main form after the call to initialisecomponents.
PatientDetails.RefreshTree = new PatientDetails.ClickEvent(this.RefreshEvent);
where PatientDetails is my usercontrol and frmMain is my Main form.
it gives me this error
e:\PRJVITREORETINAL\frmMain.cs(54): An object reference is required for the nonstatic field, method, or property 'PRJVITREORETINAL.PatientDetails.RefreshTree'
thanks
monica
|
|
|
|
|
monica2k wrote:
where this line is to be written in the main form or in the control.
monica2k wrote:
if i write this line inthe main form after the call to initialisecomponents.
That's correct.
monica2k wrote:
An object reference is required for the nonstatic field, method, or property
You've put the class name, instead of the name of an instance of the class.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
hi Christian
i am writing these statements inthe usercontrol do i have to do anything else. this refreshtree always is coming null and doing nothing
public delegate void ClickEvent();
public ClickEvent RefreshTree = null;
private void button1_Click_1(object sender, System.EventArgs e)
{
if (RefreshTree != null) RefreshTree();
}
thanks
monica
|
|
|
|
|
Yeah, like I said:
in the mainform:
void RefreshEvent()
{
theTree.Invalidate();
}
inside the create method, just after the call to initialisecomponents:
theControl.RefreshTree = new ControlType.ClickEvent(this.RefreshEvent);
RefreshTree is just a name. You set the ClickEvent to be null, and when you check, it's still null. It needs to be give a value of a method in the main form.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
hi Christian
is there any other way to do that. i cannot make it to work.
thanks
monica
|
|
|
|
|
Hi monica. No, no there is no other way that I can think of. What part is not working for you ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Look i will explain what i am doing i have a main form in which on a menu click a usercontrol is loaded that is patientdetails. now if i click on a button on usercontrol i need a tree control that is on the Main form to get refreshed. i have done evrything similar to what u said but whenever i click on the button on usercontrol it does nothing.
This is the code for menuitme click to load usercontrol
PatientDetails PatDetails = new PatientDetails();
PatDetails.Visible = true;
PatDetails.Dock = DockStyle.Top;
MainPanel.Controls.Clear();
MainPanel.Controls.Add(PatDetails);
this is refresh function in the mainform
void RefreshEvent()
{
MessageBox.Show("Hi");
}
this is main form code after intialize function
// PatientDetails pd= new PatientDetails();
// pd.RefreshTree = new PatientDetails.ClickEvent(this.RefreshEvent);
in usercontrol this the button code and delegate refrence.
private void button1_Click(object sender, System.EventArgs e)
{
if (RefreshTree != null) RefreshTree();
}
public delegate void ClickEvent();
public ClickEvent RefreshTree = null;
pls tell me where and what i am doing wrong
thanks
monica
|
|
|
|
|
monica2k wrote:
PatientDetails PatDetails = new PatientDetails();
PatDetails.Visible = true;
PatDetails.Dock = DockStyle.Top;
MainPanel.Controls.Clear();
MainPanel.Controls.Add(PatDetails);
this is refresh function in the mainform
Ah... If your PatientDetails object is created on the fly, this is also where you need to set up the event. Something like
PatDetails.RefreshEvent = new PatientDetails.ClickEvent(this.RefreshEvent);
What you did is create a NEW PatientDetails object, and assign it ( and only it ) to have this event.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks a lot Christian
my problem is solved
monica
|
|
|
|
|
No worries. I said to put the code under InitializeComponents because I assuemd the control had been added in the designer. The point was just to do it after the control was created, but as soon as possible.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi everybody!
I've got this code:
static void Main(string[] args)
{
Car audi80 = ....
Car vw_beetle = ....
ArrayList cars = new ArrayList();
foreach(Car c in this method)
cars.Add(c);
}
Now I need to fill an ArrayList with all Car-classes I've defined in the Main-Method. How would I do the foreach-loop to find all variables of a certain type and add them to the ArrayList?
thanks
modified 12-Sep-18 21:01pm.
|
|
|
|
|
You can't. You need to rethink your approach. Perhaps you should just add them one by one as you create them.
Christian Graus - Microsoft MVP - C++
|
|
|
|