i have to retrieve data in my richtxtbox from my database ... how can i convert the retieved format of image source into a smily in windows form .. help please

fenrir i need to retrieve smilies from my database itself ,,, jux guide me converting this image source to a smilie in my rich text box ... please ...

Are you saving the physical image? or just the path.. Try this Click Here you will still need to first link to get your image into the Richedit.

i have ol the images in my resources
,, is it necessary i have to add them to my database , as i dont wish to alter my database by some due reasons ...... cant i use my resources to display a smiley corresponging to <img src="images/smiley-yell.png"> such column entry ... in my table

fenrir in the video ... they added picture to picturebox the same way when i did i cudn't add it to my richtext box .... please prescribe some other alternative

Once you have the image from the database the first step is done. Richtextbox doesn't have default methods for adding images so that's why i suggested that first article. Have you gone through it?

yes fenrir i studied it ... added emoticons to my resources ... as well ,, but itz getting vrry typical for me to find out wat i actualyy need .. as i simply want to match d emoticon with the php image source i have in my database ..

Okay so you have the string from the database so next you need to find the image in the resources. Did you manually add them to resources? are they inside an image list? At runtime just create a List<string> containing all your resource images. And match them by checking If (List.Contains("Image"))if it finds a match then you can can add the image from the resource.

foreach (string image in System.IO.Directory.GetFiles(@"Resources\"))
{
  MyList.Items.Add(image);
}

This is to get the initial list of your resources. Again i'm not sure how you you added the images to your project.

 void chatting()
        {

           // MessageBox.Show(videoid);
            string myconnection = "connection string";
              MySqlConnection myConn = new MySqlConnection(myconnection);

              MySqlCommand SelectCommand = new MySqlCommand("select * from livestream.users INNER JOIN livestream.chat INNER JOIN livestream.video  ON users.user_id = chat.user_id and chat.channel_id=video.video_id where chat.channel_id ='" + videoid + "' and isACTIVE=1 order by chat.chatID DESC", myConn);
              MySqlDataReader myReader;


              try
              {
                  myConn.Open();
                  myReader = SelectCommand.ExecuteReader();
                  List<string> list = new List<string>();
                  Graphics g = Graphics.FromHwnd(this.Handle);
                  ImageList photoList = new ImageList();
                  photoList.Images.Add(Image.FromFile(@"img. path"));
                  photoList.Images.Add(Image.FromFile(@"img1 path"));
                  photoList.Images.Add(Image.FromFile(@"img 2 path "));

                  while (myReader.Read())
                  {
                      string test1 = myReader.GetString("user_name");
                      string test = myReader.GetString("message");
                      test = test.Substring(test.IndexOf(";") + 1);
                      list.Add(test1 + "   " + test);
                      if (test.Contains("Image"))
                      {
                          foreach (string image in System.IO.Directory.GetFiles(@"Resources\"))
                          {
                              list.Items.Add(image);
                          }
                      }
                  }
                  chattingbox.Lines = list.ToArray();

              }
              catch (Exception ex)
              {
                  MessageBox.Show(ex.Message);
              }
              myConn.Close();


        }

m getting an error .. donno y ? i evn declared the photolist , i sent u a snapshot ...... can u c and help ..... actually m making a chat box so , the conditional logic should be that if i have msg the test condition executes else the image from resources ....

You only need to specify list.add not items

no fenrir its not happening ...

theres no error but i suppose itz nt gng in the if loop when getting an image source in message column

    Hashtable emotions;
        void createEmotions()
        {
            emotions = new Hashtable(3);
            emotions.Add(":-)", WindowsFormsApplication1.Properties.Resources.smiley_yell);
            emotions.Add(":-(", WindowsFormsApplication1.Properties.Resources.smiley_upset);
            emotions.Add(":-*", WindowsFormsApplication1.Properties.Resources.smiley_kiss);
        }
        void AddEmotions()
        {
            foreach (string emote in emotions.Keys)
            {
                while (chattingbox.Text.Contains(emote))
                {
                    int ind = chattingbox.Text.IndexOf(emote);
                    chattingbox.Select(ind, emote.Length);
                    Clipboard.SetImage((Image)emotions[emote]);
                    chattingbox.Paste();
                }
            }
        }

this code is helpin me get smilies bt only when i manuaalyy write the string :-) or such in richtextbox but thats nt my purpose ..
If (List.Contains("Image")) .. u told to put this condition .. ryt ? but my list contains itz image source not the image as i told earlier thats whr the problm stands .... my message column contains its source and not image so i need some condition ... that only pick smiley-yell.png from the source and returns the corresponding pic from resources

m getting error in my finding path of my image ..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.