Hiccup
Hiccup
CC#
Created by Hiccup on 12/3/2023 in #help
Flowlayoutpanel glitches out and distorts text when moving srollbar.
My code:
private void SplashScreen_Load(object sender, EventArgs e)
{
foreach (string surah in surahs)
{
Button button = new();
button.Width = 100;
button.Text = surah;
button.BackgroundImage = Properties.Resources._343a40;
button.ForeColor = Color.White;
button.Font = new Font(button.Font.FontFamily, 10, FontStyle.Bold);
button.UseCompatibleTextRendering = true;
surahPicker.Controls.Add(button);
}
}
private void SplashScreen_Load(object sender, EventArgs e)
{
foreach (string surah in surahs)
{
Button button = new();
button.Width = 100;
button.Text = surah;
button.BackgroundImage = Properties.Resources._343a40;
button.ForeColor = Color.White;
button.Font = new Font(button.Font.FontFamily, 10, FontStyle.Bold);
button.UseCompatibleTextRendering = true;
surahPicker.Controls.Add(button);
}
}
I have DoubleBuffer enabled in my form
2 replies
CC#
Created by Hiccup on 1/27/2023 in #help
❔ Create a picturebox_clicked event for each picturebox created
private Form1 form1 { get; set; }
readonly HttpClient httpClient = new();
public static string FolderPath = @".\Storage";
public static int picNum = 0;
public static List<string> outofScopeURL = new List<string>();

private async void Detailed_View_Load_1(object sender, EventArgs e)
{
DirectoryInfo directory = new(FolderPath);
FileInfo[] files = directory.GetFiles();
string[] FileFormats = { ".png", ".jpg", ".jpeg", ".txt" };
for (int pictureCreator = 0; pictureCreator < files.Length; pictureCreator++)
{
FileInfo file = files[pictureCreator];
if (file.FullName.EndsWith(FileFormats[3]))
{
string url = File.ReadAllText(file.FullName);
if (url != null)
{
try
{
Image gif = Image.FromStream(await httpClient.GetStreamAsync(url));
PictureBox picture = new PictureBox
{
Name = url,
Size = new(38, 38),
Image = gif,
Location = new((gif.Width * pictureCreator), 0),
SizeMode = PictureBoxSizeMode.Zoom
};
this.Controls.Add(picture);
MessageBox.Show(picture.Name);
outofScopeURL.Add(url);
picture.Click += Picture_Click;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
picNum++;
}
}
}
private Form1 form1 { get; set; }
readonly HttpClient httpClient = new();
public static string FolderPath = @".\Storage";
public static int picNum = 0;
public static List<string> outofScopeURL = new List<string>();

private async void Detailed_View_Load_1(object sender, EventArgs e)
{
DirectoryInfo directory = new(FolderPath);
FileInfo[] files = directory.GetFiles();
string[] FileFormats = { ".png", ".jpg", ".jpeg", ".txt" };
for (int pictureCreator = 0; pictureCreator < files.Length; pictureCreator++)
{
FileInfo file = files[pictureCreator];
if (file.FullName.EndsWith(FileFormats[3]))
{
string url = File.ReadAllText(file.FullName);
if (url != null)
{
try
{
Image gif = Image.FromStream(await httpClient.GetStreamAsync(url));
PictureBox picture = new PictureBox
{
Name = url,
Size = new(38, 38),
Image = gif,
Location = new((gif.Width * pictureCreator), 0),
SizeMode = PictureBoxSizeMode.Zoom
};
this.Controls.Add(picture);
MessageBox.Show(picture.Name);
outofScopeURL.Add(url);
picture.Click += Picture_Click;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
picNum++;
}
}
}
3 replies
CC#
Created by Hiccup on 12/22/2022 in #help
❔ Decoded bitmap images aren't set in the photoboxes correctly
private void BTN_Save_Click(object sender, EventArgs e)
{
string DBpath = @"Data Source=.\StudentDB.db;Version=3;";
Bitmap[] PictureBoxesBitmaps = {FirstPictureBitmap, SecondPictureBitmap, ThirdPictureBitmap };
using SQLiteConnection connection = new(DBpath);
using SQLiteCommand cmd = new(DBpath, connection);
connection.Open();
cmd.CommandText = @"DELETE FROM PictureBoxes";
cmd.ExecuteNonQuery();
foreach (Bitmap bitmap in PictureBoxesBitmaps)
{
System.IO.MemoryStream ms = new();
bitmap?.Save(ms, ImageFormat.Png);
byte[] BitmapByteArray = ms.ToArray();
var PictureBox64 = Convert.ToBase64String(BitmapByteArray);
cmd.CommandText = @"INSERT INTO PictureBoxes(Encoded) VALUES('" + PictureBox64 + "')";
cmd.ExecuteNonQuery();
}
connection.Close();
}
private void BTN_Save_Click(object sender, EventArgs e)
{
string DBpath = @"Data Source=.\StudentDB.db;Version=3;";
Bitmap[] PictureBoxesBitmaps = {FirstPictureBitmap, SecondPictureBitmap, ThirdPictureBitmap };
using SQLiteConnection connection = new(DBpath);
using SQLiteCommand cmd = new(DBpath, connection);
connection.Open();
cmd.CommandText = @"DELETE FROM PictureBoxes";
cmd.ExecuteNonQuery();
foreach (Bitmap bitmap in PictureBoxesBitmaps)
{
System.IO.MemoryStream ms = new();
bitmap?.Save(ms, ImageFormat.Png);
byte[] BitmapByteArray = ms.ToArray();
var PictureBox64 = Convert.ToBase64String(BitmapByteArray);
cmd.CommandText = @"INSERT INTO PictureBoxes(Encoded) VALUES('" + PictureBox64 + "')";
cmd.ExecuteNonQuery();
}
connection.Close();
}
I'm using this first code to encode three bitmap images into a base64 string, then I'm storing them in a SQLite database.
3 replies
CC#
Created by Hiccup on 12/12/2022 in #help
❔ Method WriteToTable(); isn't doing anything to the database file
My code:
private void button1_Click(object sender, EventArgs e)
{
WriteToTable();
}

public void WriteToTable()
{
string DBpath = @"Data Source=.\StudentInfoDB.db;Version=3;";
using SQLiteConnection SQLConnection = new SQLiteConnection(DBpath);
using var cmd = new SQLiteCommand(DBpath, SQLConnection);
SQLConnection.Open();
cmd.CommandText = "INSERT INTO Students (Name) VALUES ('Test')";
cmd.ExecuteNonQuery();
SQLConnection.Close();
}
private void button1_Click(object sender, EventArgs e)
{
WriteToTable();
}

public void WriteToTable()
{
string DBpath = @"Data Source=.\StudentInfoDB.db;Version=3;";
using SQLiteConnection SQLConnection = new SQLiteConnection(DBpath);
using var cmd = new SQLiteCommand(DBpath, SQLConnection);
SQLConnection.Open();
cmd.CommandText = "INSERT INTO Students (Name) VALUES ('Test')";
cmd.ExecuteNonQuery();
SQLConnection.Close();
}
In my database file, I have one table called Students and 3 columns called name, grade and phone number. I'm trying to ensure I correctly connected to the database so I decided I should try adding text under the Name column before I add anymore code. I expected this code to output "Text" under the "Name" column to my database file, however after I press button1 nothing happens. No errors show up and no crashes occur. I have tried debugging the code and searching online for common mistakes but sadly it did not help
7 replies
CC#
Created by Hiccup on 8/17/2022 in #help
How can I get the console to display arabic letters? [Answered]
Every arabic words just appears as question marks
6 replies