Diesel Geezer
Diesel Geezer
CC#
Created by Diesel Geezer on 10/31/2024 in #help
Problem with datagridview sorting
after i use dataGridView1.Sort(dataGridView1.Columns[0], System.ComponentModel.ListSortDirection.Ascending); The datagridview starts ordering whatever i enter automatically. I thought this was supposed to sort the data only when i ran the command, not make it sort automatically all the time how do i sort a datagridview only once without the automatic ordering
6 replies
CC#
Created by Diesel Geezer on 8/11/2024 in #help
How to check if element exists in html cefsharp
I tried this but it throws an exception that the response is null
string getElementByName = @"document.getElementsByName(""media"")[0];";
private async void jsgetval(string script)
{
responseResult = "";
JavascriptResponse response = await ytBrowser.EvaluateScriptAsync(script);
responseResult = response.Result.ToString();
Console.WriteLine(responseResult);
}
string getElementByName = @"document.getElementsByName(""media"")[0];";
private async void jsgetval(string script)
{
responseResult = "";
JavascriptResponse response = await ytBrowser.EvaluateScriptAsync(script);
responseResult = response.Result.ToString();
Console.WriteLine(responseResult);
}
9 replies
CC#
Created by Diesel Geezer on 7/23/2024 in #help
System.AccessViolationException: Attempted to read or write protected memory.
i get this exception when i change a multiline textbox to single line: Visual studio actually throws the exception at the Program.cs at the Application.Run(new Form1()); line, but i found that the issue is caused by the line valTxtBox.Multiline = false; because if i remove it i dont get the exception What is going on here?
cs
valTxtBox.TextChanged += (_, _2) =>
{
if (valTxtBox.Text.Contains('\n'))
{
disableTxtBoxAutoClose = true;
valTxtBox.Multiline = true;
valTxtBox.Height = 20 + 100;
valTxtBox.Focus();
disableTxtBoxAutoClose = false;
}
else
{
disableTxtBoxAutoClose = true;
valTxtBox.Multiline = false; <<-PROBLEM CAUSED BY THIS?
valTxtBox.Focus();
valTxtBox.Text = boxText;
disableTxtBoxAutoClose = false;
}
cs
valTxtBox.TextChanged += (_, _2) =>
{
if (valTxtBox.Text.Contains('\n'))
{
disableTxtBoxAutoClose = true;
valTxtBox.Multiline = true;
valTxtBox.Height = 20 + 100;
valTxtBox.Focus();
disableTxtBoxAutoClose = false;
}
else
{
disableTxtBoxAutoClose = true;
valTxtBox.Multiline = false; <<-PROBLEM CAUSED BY THIS?
valTxtBox.Focus();
valTxtBox.Text = boxText;
disableTxtBoxAutoClose = false;
}
4 replies
CC#
Created by Diesel Geezer on 1/14/2024 in #help
How to pass parameters to a Func
No description
28 replies
CC#
Created by Diesel Geezer on 10/30/2023 in #help
❔ Typing whitespace creates 2 more after parsing RTF from RichTextBox and then re-applying it
Lets say i press space between 2 words. When i parse the RTF and then re apply it, i get 2 more spaces so 3 in total. When i remove spaces nothing crazy happens. This happens only when i type them. Though when i type a whitespace in the end of the sentence and THEN i type a word everything is fine. This only happens when i type whitespaces between 2 already existing words/characters. What is going on here?
6 replies
CC#
Created by Diesel Geezer on 7/12/2023 in #help
❔ How to Initialize different forms using same piece of code
10 replies
CC#
Created by Diesel Geezer on 7/11/2023 in #help
❔ Output from a command line app has extra characters when redirected to my application
8 replies
CC#
Created by Diesel Geezer on 7/4/2023 in #help
❔ Problems with applying multiple styles on text in RichTextBox
Im trying to apply some styles to a piece of text in a richTextBox and they just won't work properly. Here is an example: "BeamMP Description". I want to make the last 2 characters of the word "BeamMP" bold (MP) and the second word bold and underlined. So for the first word i do this: I set the selectionStart to 0 and the selectionLength to the end of the RTBox. Then this: RTBox.SelectionFont = new Font(RTBox.SelectionFont, RTBox.SelectionFont.Style | FontStyle.Bold); Similar way to underline the word "Description" But the problem here is that the bolding magically dissapears and only the underline at the word Description is applied???
10 replies
CC#
Created by Diesel Geezer on 7/1/2023 in #help
❔ Does indexof search for the specified character at the specified index?
Or does it skip the specified index for the next?
13 replies
CC#
Created by Diesel Geezer on 6/30/2023 in #help
❔ Make a rich text box with custom formatting codes
is there any way to make a richtextbox with custom formatting codes? When i make a piece of text bold for example, instead of doing it like this: cat -> \b cat\b0 do it like this cat -> \customBoldCode cat\EndCustomBoldCode
17 replies
CC#
Created by Diesel Geezer on 3/19/2023 in #help
How can i remove a substring from index i to first index of a or b character
6 replies
CC#
Created by Diesel Geezer on 3/15/2023 in #help
how to get clicked button of context menu strip
24 replies
CC#
Created by Diesel Geezer on 2/11/2023 in #help
❔ BinaryFormatter does not serialize/deserialize the Tags of listview items
so i have a listview that i want to serialize and then desirialize. I store some values in the tags of each listview item. Problem is that after i clear the listview and deserialize the file, the tags of each listview item is gone. I don't know if this is a problem of the writer or the reader, but i guess its because of the writer skipping the tag property. How can i overcome this issue?
public bool WriteToBinaryFile(string filePath, ListView listview)
{
bool result = false;
FileStream fsWrite = File.Open(filePath, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
try
{
BinaryFormatter binfmt = new BinaryFormatter();
InvokeIfRequired(listview, () => { binfmt.Serialize(fsWrite, new ArrayList(listview.Items)); });
result = true;
}
catch (Exception a) { pushError(a.ToString()); result = false; }
try { fsWrite.Close(); }
catch (Exception) { }
return result;
}

public bool ReadFromBinaryFile(string filePath, ListView listview)
{
bool result = false;
FileStream fsRead = File.Open(filePath, FileMode.Open, FileAccess.Read);
try
{
// deserialize
binfmt = new BinaryFormatter();
ArrayList deserialized_array_list = (ArrayList)binfmt.Deserialize(fsRead);
Array listviewitem_array = (deserialized_array_list).ToArray(typeof(ListViewItem));
listview.Items.AddRange((ListViewItem[])listviewitem_array);
result = true;
}
catch (SerializationException) { } //exclude this exception
catch (Exception a) { pushError(a.ToString()); result = false; }
try { fsRead.Close(); }
catch (Exception) { }
return result;
}
public bool WriteToBinaryFile(string filePath, ListView listview)
{
bool result = false;
FileStream fsWrite = File.Open(filePath, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
try
{
BinaryFormatter binfmt = new BinaryFormatter();
InvokeIfRequired(listview, () => { binfmt.Serialize(fsWrite, new ArrayList(listview.Items)); });
result = true;
}
catch (Exception a) { pushError(a.ToString()); result = false; }
try { fsWrite.Close(); }
catch (Exception) { }
return result;
}

public bool ReadFromBinaryFile(string filePath, ListView listview)
{
bool result = false;
FileStream fsRead = File.Open(filePath, FileMode.Open, FileAccess.Read);
try
{
// deserialize
binfmt = new BinaryFormatter();
ArrayList deserialized_array_list = (ArrayList)binfmt.Deserialize(fsRead);
Array listviewitem_array = (deserialized_array_list).ToArray(typeof(ListViewItem));
listview.Items.AddRange((ListViewItem[])listviewitem_array);
result = true;
}
catch (SerializationException) { } //exclude this exception
catch (Exception a) { pushError(a.ToString()); result = false; }
try { fsRead.Close(); }
catch (Exception) { }
return result;
}
10 replies
CC#
Created by Diesel Geezer on 1/8/2023 in #help
Access file that is being used by another application using FileStream
public void WriteToBinaryFile(string filePath, ListView listview)
{
FileStream fsWrite = File.Open(filePath, FileMode.Create, FileAccess.ReadWrite); // I GET AN EXCEPTION HERE
BinaryFormatter binfmt = new BinaryFormatter();
InvokeIfRequired(listview,()=> { binfmt.Serialize(fsWrite, new ArrayList(listview.Items)); });

fsWrite.Close();
}
public void WriteToBinaryFile(string filePath, ListView listview)
{
FileStream fsWrite = File.Open(filePath, FileMode.Create, FileAccess.ReadWrite); // I GET AN EXCEPTION HERE
BinaryFormatter binfmt = new BinaryFormatter();
InvokeIfRequired(listview,()=> { binfmt.Serialize(fsWrite, new ArrayList(listview.Items)); });

fsWrite.Close();
}
13 replies
CC#
Created by Diesel Geezer on 1/6/2023 in #help
❔ assign a local string function to a string variable
string parameters = ";mediaType = " + mediaTypeCombo +";" + string res() { if (mediaTypeCombo.Text == "mp3") { return ""; } else return mediaTypeCombo.Text; };
string parameters = ";mediaType = " + mediaTypeCombo +";" + string res() { if (mediaTypeCombo.Text == "mp3") { return ""; } else return mediaTypeCombo.Text; };
Is something like this possible?
8 replies