|
It works on sub items if you set FullRowSelect to true... wired bahavior...
|
|
|
|
|
This is a semi-solution.
Subclassing the ListView and overriding WndProc , listen for the left mouse button up message and raise the MouseUp event passing the correct parameters.
With a bit more work you may be able to use a flag to allow/disallow MouseUp messages to supress the erroneous one that you are getting.
public class FixedListView : ListView
{
private const int WM_LBUTTONUP = 0x0202;
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_LBUTTONUP)
{
Point point = new Point(((int)m.LParam) & 0x0000FFFF, (int)m.LParam >> 16);
OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, point.X, point.Y, 0));
return;
}
base.WndProc(ref m);
}
}
WM_LBUTTONUP Message[^]
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.(Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Thanks for the proposed semi-solution. I put together different pieces and came up with this solution which seems to do what I want First, I leave the MultiSelect property set to false and set FullRowSelect to true . Then I use this code:
public class CustomListView : ListView
{
public CustomListView()
{
InitializeComponent();
}
bool fakeMouseUp = false;
bool mouseDownOnItem = false;
protected override void OnMouseDown( MouseEventArgs e )
{
mouseDownOnItem = HitTest( e.Location ).Item != null;
Debug.WriteLine( "OnMouseDown" );
base.OnMouseDown( e );
}
protected override void OnMouseUp( MouseEventArgs e )
{
if( mouseDownOnItem || fakeMouseUp )
{
Debug.WriteLine( "OnMouseUp" );
mouseDownOnItem = false;
fakeMouseUp = false;
base.OnMouseUp( e );
}
}
protected override void WndProc( ref Message m )
{
if( !mouseDownOnItem && m.Msg == 0x0202 )
{
fakeMouseUp = true;
Point point = new Point( ((int) m.LParam) & 0x0000FFFF, (int) m.LParam >> 16 );
OnMouseUp( new MouseEventArgs( MouseButtons.Left, 1, point.X, point.Y, 0 ) );
}
base.WndProc( ref m );
}
}
But I always have a feeling of wasted time when I need to do such workarounds for weird .NET behaviour. Why on Earth do I get a MouseUp event when the mouse button was not physically released?
|
|
|
|
|
Hello
I need help in editing a datagridview's row.
I have a grid which is dynamically populated in a way that user adds some data in the form of rows.
Now, I want to give the user the option to edit the row as well. I want to provide the functionality just like asp.net's editable gridview. that is, i want that when a user click on a cell to edit it, a dropdown should be displayed containing selected values. I also want that user may have a cell with text 'edit' and user should click that to start editing the row. as soon as the user click the 'edit', the text should be changed to 'update'.
Please guide me for it.
saq!b
"Our scientific power has outrun our spiritual power. We have guided missiles and misguided men."
Dr. Martin Luther King Jr.
|
|
|
|
|
Look into DataGridViewComboBoxColumn and DataGridViewButton column. That must suite your needs.
|
|
|
|
|
thanks danish.
i was just looking into DataGridViewComboBoxColumn. please tell me if it is possible to change the column type of a row at runtime?
saq!b
"Our scientific power has outrun our spiritual power. We have guided missiles and misguided men."
Dr. Martin Luther King Jr.
|
|
|
|
|
Set the DisplayStyle property to nothing for the combobox column. HTH.
|
|
|
|
|
can you write the syntax here plz?
saq!b
"Our scientific power has outrun our spiritual power. We have guided missiles and misguided men."
Dr. Martin Luther King Jr.
|
|
|
|
|
Hi,
Go through this code........
<asp:GridView ID="gv" runat="server" AutoGenerateColumns="False"
BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="3px"
CellPadding="4" CellSpacing="2" ForeColor="Black" Height="285px"
onrowcancelingedit="gv_RowCancelingEdit" onrowdeleting="gv_RowDeleting"
onrowediting="gv_RowEditing" onrowupdating="gv_RowUpdating" Width="493px">
<FooterStyle BackColor="#CCCCCC" />
<RowStyle BackColor="White" />
<Columns>
<asp:BoundField DataField="Name" HeaderText="Item Name" />
<asp:TemplateField>
<HeaderTemplate>
<asp:Label ID="lblHead" runat="server" Text="Price"></asp:Label>
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lblPrice" runat="server" Text='<%#Eval("Price")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="ddl1" runat="server">
<asp:ListItem>1000</asp:ListItem>
<asp:ListItem>2000</asp:ListItem>
<asp:ListItem>3000</asp:ListItem>
<asp:ListItem>4000</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
<asp:ButtonField DataTextField="Description" HeaderText="Desription" />
<asp:CommandField ShowCancelButton="true" ShowDeleteButton="true" ShowEditButton="true" />
</Columns>
<PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
</asp:GridView>
|
|
|
|
|
i found a solution for invalidoperation in net , force handle to create. but i get the exception still.
let me explain the situation
in Form A ,in the constructor i call a method named startmodule(), in this method it invokes a static delegate that is in From A ,from a separate thread. so in the Form A constructor i called this.handle
as the first step, but still i get the exception any idea about what is wrong..!
thanx in advance.
|
|
|
|
|
While inside a Form constructor, the Form does not yet exist. Can't you postpone your failing stuff to some later point, say the Load event or even maybe the Shown event?
|
|
|
|
|
I would recommend moving the call to startmodule() out of the constructor and into the form's OnLoad() method. Do you work after the base.OnLoad() call, and I expect you'll find things work properly.
|
|
|
|
|
I don't know if this is relevant to your situation (but you may find it useful sometime even if not), you can force the handle to be valid inside a constructor by getting the value of the Handle property i.e.
public FormA()
{
IntPtr handle = Handle;
}
More info here[^].
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.(Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
modified on Tuesday, August 24, 2010 3:37 PM
|
|
|
|
|
Hi,
I have some collection that hold some struct.
Its look like this :
struct PointColor
{
Point p;
Color c;
public PointColor(Int32 x, Int32 y, Color c)
{
p = new Point( x, y );
this.c = c;
}
};
private List<PointColor> PointColorCollection = new List<PointColor>();
My Question is:
Because the object in the collection are value type - does this collection cleaning can cause somehow the GC to run ?
If the answer is 'Yes' - is there some way to optimize this code and avoid GC to run ?
Thanks.
|
|
|
|
|
Do yourself a favor, and just don't worry about it. The garbage collector works beautifully in almost all situations. As long as you keep a reference to it, no matter how indirect, it won't be trashed. Whether it's a class or struct doesn't really matter.
|
|
|
|
|
It's next question about manipulating GC in last few days... Sometimes I have the feeling, that some people think, that if they force GC to work they are better developers... What for? If application uses to much memory it's probably your fault, not the GC not working properly.
Don't forget to rate answer, that helped you. It will allow other people find their answers faster.
|
|
|
|
|
There seems to be some kind of wide spread incomfort (lacking a better term in the moment) with this basic concept of CLR. What I see is a lot of folks who are simply told "tommorrow, you start writing .NET code"... So they do start applying the 'learning by doing' method...
|
|
|
|
|
Yanshof wrote: does this collection cleaning can cause somehow the GC to run ?
No.
However not the no you are hoping for: the GC will run when you either force it to run (say calling GC.Collect, a bad idea) or when you do something (typically execute a new Something) that needs more memory than is currently available. Freeing/clearing something will not cause the GC to run (except when you would be extremely nasty and have objects that allocate new stuff in their finalizer, a horrible thought it is).
I think you have been asking the wrong question. Either you are worried about performace or you already are having performance trouble. Then you should give more contextual information and ask a more open question.
The code shown basically represents a pixel; I do hope you are not using that to construct an entire image.
|
|
|
|
|
I don't understand your questions... First you ask if "cleaning" a collection causes GC to run. - Answer is Maybe... Because GC is hardly predictable and depends on the memory use of your whole application. You can force garbage collection with GC.Collect - but this is not good practice...
Then you say you want to avoid GC to run? And what the hell you mean with "because the objects in the collection are value types"?
Maybe you tell us what your problem is? Performance, memory, general interest? How many values will be in the collection and what you mean with "cleaning"?
|
|
|
|
|
1. my problem is performance.
My application need to deal with a lot of data that comes from some other application and i afraid that if the GC will start run - then i will miss some of the packages that the other application is sending to me.
2. The collection is holding ~100000 items.
3. Beside this, i what to know better how the GC is working ( under the hood ) and i still have open question about it ( and still i don't understand some issues ).
This is why i asking so many question on the last couple of days about the GC and how its work.
|
|
|
|
|
@1: Don't worry, as long as you keep a reference to your data GC will not free any memory. I don't understand how you can "loose data" because of the GC? If you loose your reference to the data, it's lost anyway...
@2: Maybe here's the root of your perfomance problems? Depends on what you are doing with your collection...
Think about your application architecture (Maybe you don't have to hold all this items in memory?)
@3: Coming from years of manual memory handling with C/C++, and using .NET now since Version 1.0, I can tell you there were hardly any circumstances when I wanted to handle the
memory allocation/freeing for myself again. From my view the GC works pretty perfect, and the best thing: You don't have to know much about it. Whenever I ran into memory-related performance problems it was because of wired requirements or bad designed application architecture. First make shure you got this right, and if memory-handling is still the problem you may want to do some tricks with "unsafe" or "native code", at least the critical parts? Or use some other technics like memory-mapped-file etc. (do a search here on codeproject)
|
|
|
|
|
Hello All,
I am scraping some text from a html page and writing to a text file.
after every line extraction i am adding the text to list & in the end i am writing to a text file.
in one pass i am getting text as
Email: ptadeep.g@someemail.com Membership Type:
in this line i want only the email id , Please is there any method to remove the words Email & Membership Type from the string and then add only email id to list ??
|
|
|
|
|
|
Thanks Richard for the response.
I tried with
IndexOf ,LastIndexOf & str.Substring methods and got the output.
|
|
|
|
|
if you have problems dealing with strings, the natural approach is to read up on the String class. It has a lot of methods, and whatever your problem is, there will be one or more solutions.
|
|
|
|