i have a web browser that it's edit mode is on and sum users work with it.
users can insert image but not with UI of web browser control but they select an image from a form and i insert them by code below :
private void insert_image_btn_Click(object sender, EventArgs e)
{
HtmlElement userimage = webBrowser1.Document.CreateElement("img");
userimage.SetAttribute("src", "image location");
userimage.Id = "imageid";
webBrowser1.Document.Body.AppendChild(userimage);
}
and i want to write some code that users can change the alignment of any image that inserts in web browser, i give them a combo Box that can select the alignment they want. but problem is that when they click on an image then change the combo Box value i can't find what image was clicked by user to change alignment.
how i can find what image are selected?
i find it's solution
private void Document_ContextMenuShowing(object sender, HtmlElementEventArgs e)
{
e.ReturnValue = false;
selectedElement = webBrowser1.Document.GetElementFromPoint(e.MousePosition);
string tag = selectedElement.TagName;
if (tag == "IMG")
{
alignmentTscb.Enabled = true;
alignmentTscb.Text = selectedElement.GetAttribute("align");
}
else
alignmentTscb.Enabled = false;
}
selectedElement
is the element that user right Click on it.