Question about using delegates with a string paramater to return a
ListViewItem object...
All,
I have a thread and I want this thread to post messages to the main GUI
thread using a delegate. This is my code fragment:
ListViewItem lview = m_form.Invoke( m_form.m_Delega teAddItem, new object[]
{"hello"} );
This does not compile; m_form is a reference to my main form,
m_DelegateAddIt em is obviously my delegate.
I have two questions, how can I pass a string to this delegate and how can I
get the return value back from this delegate?
My delegate is definied as such:
(AddItem is my function for m_DelegateAddIt em)
private ListViewItem AddItem( string str )
{
return m_ctrlReq.Items .Add( str );
}
I want to use the listviewitem i get returned to append data to this
specific row in my list box.
Thanks
PT 2 1627
Max Adams <ru************ @hotmail.com> wrote: Question about using delegates with a string paramater to return a ListViewItem object...
All,
I have a thread and I want this thread to post messages to the main GUI thread using a delegate. This is my code fragment:
ListViewItem lview = m_form.Invoke( m_form.m_Delega teAddItem, new object[] {"hello"} );
This does not compile
When saying that something doesn't compile, *always* say what the
compilation error is.
In this case, at a guess, just casting the return value of
m_form.Invoke to ListViewItem will solve things. If it doesn't,
could you post a short but complete program which demonstrates the
problem?
See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Sorted it.
m_lview = (ListViewItem)m _form.Invoke( m_form.m_Delega teAddItem, new
string[] { "A", "A", "A", "A", "A"} ); I have a thread and I want this thread to post messages to the main GUI thread using a delegate. This is my code fragment:
ListViewItem lview = m_form.Invoke( m_form.m_Delega teAddItem, new object[] {"hello"} );
This does not compile; m_form is a reference to my main form, m_DelegateAddIt em is obviously my delegate.
I have two questions, how can I pass a string to this delegate and how can
I get the return value back from this delegate?
My delegate is definied as such: (AddItem is my function for m_DelegateAddIt em)
private ListViewItem AddItem( string str ) { return m_ctrlReq.Items .Add( str ); }
I want to use the listviewitem i get returned to append data to this specific row in my list box. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Vanessa |
last post by:
With this program I can do one selection,
but upon the second I get an error where
///////////////// is indicated. Please help.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
|
by: Prasad Karunakaran |
last post by:
I am using the C# DirectoryEntry class to retrieve the Properties of
an user object in the Active Directory. I need to get the First Name
and Last Name as properties. I know it is not supported with the ADSI
NT Provider and only supported in the LDAP Provider.
So given an UserId (UID) how can I read the First Name and Last Name
using LDAP Provider. If anybody can help me with a C# sample code it
would of great help.
Thanks in advance.
|
by: Natalia DeBow |
last post by:
Hi,
I am working on a Windows-based client-server application. I am involved in
the development of the remote client modules. I am using asynchronous
delegates to obtain information from remote server and display this info on
the UI.
From doing some research, I know that the way my implementation works today
is not thread-safe, because essentially my worker thread updates the UI,
which is BAD. So, here I am trying to figure out how...
|
by: sorpor |
last post by:
I am trying to create a custom listviewsorter by implementing IComparer. My
listview has check boxes and the purpose is to move checked item to top of
list. They all will be sorted ascendingly. It throws error "-1 is not a
valid index" when the sorting is done with listview. I have no problem using
the same custom sorter for an arraylist of listviewitems. A bug in listview
control? Any suggestion?
Thanks,
-sorpor
|
by: naikrovek |
last post by:
Hello all.
I have a ListView on a form, that has columns added at design-time but
will be populated run-time. So, I know what the columns will be, and I
know that I will have an arbitrary number of 'rows' in the ListView,
anywhere from 1 to 100 or even 1000.
The purpose of the program is to allow a user to keep an eye on tickets
in a ticketing database.
| |
by: > Adrian |
last post by:
I am getting these errors:
DrawListViewItemEventArgs' could not be found
DrawListViewSubItemEventArgs' could not be found
DrawListViewColumnHeaderEventArgs' could not be found
I am already referencing both:
System.Drawing
System.Drawing.Design
|
by: > Adrian |
last post by:
In VS 2003 I could sort a column in a list view using the code below,
hover, in V2005 I get this error:
Error 1 Using the generic type 'System.Collections.Generic.IComparer<T>'
requires '1' type arguments
What to do?
Please tell me concretely how to get rid of this error in terms of code.
Many thanks,
|
by: damiensawyer |
last post by:
Hi,
Can someone please explain to me something about delegates?
My understanding is as follows. A delegate is basically an object that
can hold a reference to a "method" somewhere. That is, it's
essentially a pointer to a piece of code somewhere else in memory.
It therefore (to me anyway) makes sense to define delegates with their
signatures and be able to use those signatures at different points in
|
by: tshad |
last post by:
I am just getting started with events and had a couple of questions on why
they do what they do.
If you have a textbox and you want to handle an event you can just do:
this.TextBox2.TextChanged += new
EventHandler(TextBox2_TextChanged);
and then have the function.
void TextBox2_TextChanged(object sender, EventArgs e)
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |