I have a RichTextBox called rchEditor1.
I have 2 Buttons called btnAdd ,btnAddImage and the list box where the names of Images are stored is called lstboximages.
When I press btnAddImage , an Image from DataBase is Added onto the richtextbox.
The Code I am Using is
SqlConnection cn2 = null;
SqlCommand cmd2 = null;
SqlDataReader reader2 = null;
String gettext = "select Image from tblAddImage where ImageName = '" + lstboxImages.SelectedValue + "'";
cn2 = new SqlConnection("User id=cmslogin;password=cmsunlock;database=CMS2;Data source=primasqltst\\qa");
cn2.Open();
cmd2 = new SqlCommand(gettext, cn2);
reader2 = cmd2.ExecuteReader();
while (reader2.Read())
{
string test = reader2[0].ToString();
string Field2 = null;
Field2 += rchEditor1.Rtf.Insert(rchEditor1.Rtf.Length - 4, test);
rchEditor1.Rtf = Field2;
}
reader2.Close();
When I press btnAdd, a text is added onto the richtextbox.
The Code I am using is as follows.
string list = "<<" + treeContractViews.SelectedNode.Text + "." + lstboxViews.SelectedValue.ToString() + ">>";
rchEditor1.Rtf = rchEditor1.Rtf.Insert(rchEditor1.Rtf.Length - 4, list);
So My Problem is listed below.
So How should I place the image or text exactly at the position I desired with out disturbing other text or images.
Please Help Me