Hiccup
Hiccup
CC#
Created by Hiccup on 1/27/2023 in #help
❔ Create a picturebox_clicked event for each picturebox created
What I'm trying to achieve: I'm trying to look in a specific directory for text files, then I want to read the files and extract the URL present in them. After I got all of the URLs of all the text files present in my folder, I added them into a list so I could use them with their respective picturebox For example, when URL1 has picture1 and URL2 has picture2, I want to set the text of the clipboard to URL1 when picturebox1 that has picture1 applied to it is clicked. What I have tried: I have tried making a new picturebox_Clicked event in the pictureCreator for loop but the problem is that the event is always applied to the last picturebox created. Any help is much appreciated
3 replies
CC#
Created by Hiccup on 12/22/2022 in #help
❔ Decoded bitmap images aren't set in the photoboxes correctly
public Form1()
{
InitializeComponent();
RefreshData();
using SQLiteConnection PicCheckerConnection = new(DBpath);
using var cmd = new SQLiteCommand(DBpath, PicCheckerConnection);
PicCheckerConnection.Open();
for (int i = 0; i <= 4; i++)
{
int PhotoSelect = i + 1;
cmd.CommandText = "SELECT * FROM PictureBoxes ORDER BY Encoded ASC LIMIT " + PhotoSelect + "," + PhotoSelect;
cmd.ExecuteNonQuery();
using (SQLiteDataReader read = cmd.ExecuteReader())
{
while (read.Read())
{
string Base64Image = read.GetString(0);
byte[] bytes = Convert.FromBase64String(Base64Image);
Stream stream = new MemoryStream(bytes);
if (i == 1) { pictureBox1.Image = Image.FromStream(stream);}
if (i == 2) { pictureBox2.Image = Image.FromStream(stream);}
if (i == 3) { pictureBox3.Image = Image.FromStream(stream);}
}
read.Close();
}
}
public Form1()
{
InitializeComponent();
RefreshData();
using SQLiteConnection PicCheckerConnection = new(DBpath);
using var cmd = new SQLiteCommand(DBpath, PicCheckerConnection);
PicCheckerConnection.Open();
for (int i = 0; i <= 4; i++)
{
int PhotoSelect = i + 1;
cmd.CommandText = "SELECT * FROM PictureBoxes ORDER BY Encoded ASC LIMIT " + PhotoSelect + "," + PhotoSelect;
cmd.ExecuteNonQuery();
using (SQLiteDataReader read = cmd.ExecuteReader())
{
while (read.Read())
{
string Base64Image = read.GetString(0);
byte[] bytes = Convert.FromBase64String(Base64Image);
Stream stream = new MemoryStream(bytes);
if (i == 1) { pictureBox1.Image = Image.FromStream(stream);}
if (i == 2) { pictureBox2.Image = Image.FromStream(stream);}
if (i == 3) { pictureBox3.Image = Image.FromStream(stream);}
}
read.Close();
}
}
Then I wrote this code where it selects all three base64 strings from the SQLite database, decodes them and puts them in their pictureboxes respectively, the first base64 string --> the first picture box, second base64 string --> second picture box, and third base64 string --> third picture box. However, when the program decodes the base64 strings and applies the images to the pictureboxes, the order is messed up. The second decoded image is set in the first picturebox, and the third decoded image is set in the second picturebox and the first decoded image is not set in any of the pictureboxes. I have tried debugging and changing the value of i, but sadly they did not help.
3 replies
CC#
Created by Hiccup on 8/17/2022 in #help
How can I get the console to display arabic letters? [Answered]
Thank you
6 replies