|
Thanks Ed.
I thinks I've got it sussed now
ListViewItem has a Position property which is a Point (why Position and not Location - who knows), TreeNode has a property Bounds which is a Rectangle which includes a Point which is called Location. Both objects have a property which gets you to their respective masters (ie a ListView or TreeView) which have an ImageList property, both ListItem and TreeNode have imageList indices so you can offset by the Image.Size.Width property - except that TreeNode Bounds has already done that for you - and make sure you differentiate between int indexed imagelists and string indexed image lists.
I am now very close to having a "LabelEdit" that provides the functionality of a TextBox++ , it'll be my first contribution to CP.
Cheers PhilD
|
|
|
|
|
pjd1001 wrote: it'll be my first contribution to CP
Look forward to seeing it
Formula 1 - Short for "F1 Racing" - named after the standard "help" key in Windows, it's a sport where participants desperately search through software help files trying to find actual documentation. It's tedious and somewhat cruel, most matches ending in a draw as no participant is able to find anything helpful. - Shog9
|
|
|
|
|
I have created a listview in my C# form and when i add an item through my code I change the background color of my cells/rows. However, when i scroll over them at runtime the color defaults back to white and then they stay white. I have different tab pages in my form. If I switch to a different tab page and then come back the colors will be back where they were until they are selected or scrolled over again. Is this simply a glitch in VS? I have no idea how to fix it. When I enter items into the listview I am using the following code.
ListViewItem li = new ListViewItem(le.TimeStamp.ToString());
//Allows us to use different fonts, backgroud colors, etc. for individual items within a row on the
//list view and for entire rows themselves
li.UseItemStyleForSubItems = false;
string mt = "";
//depending on the type of message that is being logged to the case tab a color indicator is chosen
//to be displayed in the "Indicator" column
switch(le.MessageType)
{
//display a green indicator bar and a message for "Informational"
case "Informational":
{
mt = "Informational";
li.SubItems.Add(mt);
li.SubItems.Add("");
li.SubItems.Add(le.Message);
li.SubItems[2].BackColor = Color.Green;
CaseLogListView.Items.Add(li);
break;
}
I have posted this issue on numerous websites and no one will respond with any kind of solution. Please help.
-- modified at 20:32 Tuesday 13th June, 2006
|
|
|
|
|
I had a little trouble reproducing your problem. Do you have hot tracking on? I noticed it did it when you had hot tracking. Without it, it seems to work fine. I'm assuming you're using "detail" mode.
Logifusion[^]
|
|
|
|
|
I would agree that it has something to do with the hot tracking. I don't know what yet, but I'm working on it.
|
|
|
|
|
Hmm. It's actually the hover selection property. As you mouse over the row, it is selected, making it white. This property must be set to true when hot tracking is set to true - it won't accept another value. If you set it to true while hot tracking is false, the problem still occurs.
Maybe you could owner draw the cells to deal with this problem...?
|
|
|
|
|
fghfghfghfgh
suresh babu.k
|
|
|
|
|
|
Do you have the HotTracking property on the ListView set to true?
Logifusion[^]
|
|
|
|
|
no i wish it was that easy
|
|
|
|
|
Hi, i have my mainform referenced in my dll proj. I am wondering how i can read a text file and send the text to a textbox on the mainform:
public static void ReadText(string source)
{
using (StreamReader sr = new StreamReader(source))
{
String file = sr.ReadLine();
}
}
Thanks alot for your help!
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
either pass the textbox as an argument, or make a method in the mainform app available as a delegate to the DLL which it can invoke when it reads the data. Define the delegate in the dllClass which I assume is referenced in your mainform a'la, also define one of these as a property with get/set accessors
"public delegate void _TextProcessor(string _theText);"
public _TextProcessor TextProcessor { get { return theTextProcessor } set { theTextProcessor = value } }
in you mainform write a method that conforms to the delegates "template" and assign it to the exposed property:
private void myTextProcessor(string _text)
{
this.textBox.Text = _text;
this.theBox.Invalidate();
}
dllClass.TextProcessor = myTextProcessor;"
replace your comment in the dllClass with something like "theTextProcessor(sr.ReadLine());"
|
|
|
|
|
Thanks!
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
Hey pjd i tested out what you gave me and i tried it out but i'm having a few problems. If you could help me out that would be great!
On the mainfrm it isn't giving me the option to add the delegate "TextSender". Once i get that i should be fine with the app part of it. What i would want to put here is textReader.TextSender = ProcessText;
public partial class mainfrm : Form
{
public mainfrm()
{
InitializeComponent();
}
private void rfButton_Click(object sender, EventArgs e)
{
OpenFileDialog open = new OpenFileDialog();
open.Title = "Select A Text File";
open.InitialDirectory = @"C:\";
open.Filter = "Supported Files|*.txt";
open.Multiselect = false;
open.ReadOnlyChecked = false;
if (open.ShowDialog() == DialogResult.OK)
{
foreach (string filename in open.FileNames)
{
textRead.ReadText(open.FileName);
}
}
}
private void ProcessText(string text)
{
textBox1.Text = text;
textBox1.Invalidate();
}
}
The compiler complains when i try to add this.TextSender(sr.ReadLine()) giving the message below. But I need to have that method static so i can call it from the mainfrm (as shown above).
public class textRead
{
public delegate void AddText(string text);
public AddText TextSender
{
get
{
return TextSender;
}
set
{
TextSender = value;
}
}
public static void ReadText(string source)
{
using (StreamReader sr = new StreamReader(source))
{
this.TextSender(sr.ReadLine());
}
}
}
Thanks again for your help!
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
I don't see where TextSender gets a value - TextSender is a property which needs storage to put its data - in textRead class, under delegate definition put " private AddText _textSender;" that'll set aside some memory for an AddText object.
in the TextSender Property get will return _textSender set will asign _textSender to value
In mainform you need to give textRead.TextSender a value, suggest you do in in constructor textRead.TextSender = ProcessText;
In ReadText suggest you invoke this._textSender
Why not use a handle "because the whip fell off the handle and the wheel went in a rut"
c'ya pjd;)
|
|
|
|
|
Thanks pjd for your help
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
This may sound oldfashioned ...
Use a handle ...
Don't you also love the code?
|
|
|
|
|
Hi,
I'm studing VS 2005 C# XPRESS Ed. and I'm facing with reporting. It seems Crystal Report isn't available for VS XPRESS Ed., is it? Can someone help me? I need to import some library into my c# prj (CrystalDecisions.*) but I don't know how to provide them...
Thanks in advance
|
|
|
|
|
*shameless self-plug*
See sig
----------------------------
Be excellent to each other
EasiReports[^] My free reporting component for WinForms.
|
|
|
|
|
Good Afternoon,
I've kinda hit a brickwall today with something I thought would be pretty straight forward. I have a form that loads after checking user's login credentials. I have all the "processing" functions in an independant class that I use often in other projects. The objects on the form are set to public. I understand that a c# form is a class so I thought the following would work but I can't seem to get access to manipulate the objects on the form.
DataGridView dgCallMonitor = (DataGridView)frmOpsCon.ActiveForm.Controls["dgCallMonitor"];
Any help or pointer to what I'm doing wrong would be appreciated
JB
|
|
|
|
|
What I usually do in a case like that is make a public property on the form in question exposing the control then I can just access it through the property.
|
|
|
|
|
An alternative to exposing the form controls to the "processing" class, which would encumber it with the overheads of Windows.Forms etc, is to use delegate methods. See my post to the nearby question from teejayem titled "Dll question". I've used this method in classes that are used in three environments gui, command line and server, works well.
cheers phild
|
|
|
|
|
Hello,
Is it necessary to ensure thread-safety for an instance of the System.String class? I understand that String s are immutable types, but I was unsure if this necessarily means that an instance of the System.String class is thread-safe for multiple readers and multiple writers.
In my application, several String s which belong to an instance of a class will be both accessed and changed from multiple threads. I can easily put a lock on them and make sure the operations do not clash, but if I do not have to waste time waiting for the lock because the type is naturally thread-safe then of course I do not want to.
I understand that this may be a simple question, but for some reason I cannot find a clear universal answer to the question.
Thanks in advance!
Sincerely,
Alexander Wiseman
|
|
|
|
|
They are not threadsafe by default. Only static variables are automatically threadsafe.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thanks for your reply. I am still confused, however, because in the MSDN documentation, it says this about a System.String (and it makes no distinction between static members and instance members):
Quote from MSDN System.String Overview
Thread Safety
This type is safe for multithreaded operations.
End quote from MSDN
Furthermore, just because a variable is declared to be static does not mean that it is thread safe. I was under the impression that the programmer had to make sure that variables, even static ones, were thread safe.
That being said, my original confusion remains, because it seems like, from the MSDN documentation, there is nothing required on the part of the user of the System.String class to ensure thread safety. What little I have read concerning "immutability" of the string type would support this. On the other hand, if I am doing multiple write operations and multiple read operations, is there going to be a problem?
Thanks again.
Sincerely,
Alexander Wiseman
|
|
|
|