.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Easy Web
Imran Ghani
Post New Web Links

Owner-drawn ListView and nonstandard subitem size: selection problems.

Posted By:      Posted Date: August 27, 2010    Points: 0   Category :Windows Application
 
Hello, I have a ListView whose first column is owner-drawn and items can be selected (I had to jump through hoops to draw the focus rectangle correctly). The problem is, my custom drawing displays the text in a wider font than normal, and only for this column. And when I click an item to select it, the right part of the text does not react, because the listview doesn't "know" there is text there (since it "thinks" the text is smaller). How can I correct this? Is there a "hit test" or "measure item" event or something, to tell the list view to consider a wider zone for clicks?


View Complete Post


More Related Resource Links

A layout, mouse selection, ListView problem/question

  
I'm having a problem with a particular layout scenario, and how it interacts with a left mouse click in certain situations. I have 3 rows in a Grid.  The first is a ListView (Master), with the Row Height set to '*'. It's ItemSource is bound to a collection in a ViewModel, and its SelectedItem is bound to a value in the ViewModel.  When the SelectedItem is null, it should take up its entire container (the other 2 rows are invisible). The second row is the GridSplitter.  It's visibility is bound to a value in the ViewModel.  It's only visible when the SelectedItem in the Master ListView is not null.  It's GridRow height is set to Auto, and it's height is explicitly set to 5 (via a style). The third row is a sub-ListView that shows Detail data for the Master SelectedItem in the top ListView.  It's GridRow Height is set to zero by default, and if an item is selected in the Master ListView, it should become visible and have a set height (400 to start, via a binding on the Height of the row). The desired effect is that when an item is selected in the Master ListView, the Detail ListView becomes visible and the GridSplitter allows you to resize the top and bottom as needed.  If necessary, the ScrollBars become visible in the Master ListView to show any items that are now obscured by the Detail ListView (via the automatic scrolling featur

Problem with listview selection

  
I have the following problem (which I have seen documented in many places with no solution).  I populate a listview.  The steps I use are: Set the ItemsSource to nothing (VB) Set the ItemsSource to the collection to be bound to Set the selected item to nothing (VB) Set the selected item to the first item in the collection The problem is that when I use the down arrow key to change selection in the listview, the first time I use the down arrow nothing happens.  After that first glitch everything works.  I have seen many "solutions" but none that work. Any ideas?? Thanks LLoyd Sheen

ListBox/ListView Selection

  
We are implementing drag/drop on ListBox/ListView items with the extended selection mode. The extended selection mode allows multiple items to be selection simultaneously by holding the shift or control key while selecting additional items.   In Windows Explorer, when an individual item among a group of selected items is clicked, all of the other items are not deselected until the up-click event. This allows an individual to select the desired group and then click and drag this group as a whole to the desired destination.   In WPF, the group appears to be deselected and the individual item selected on the down-click event. This means that in order to drag a group of items, you must hold shift, click and hold the mouse on the desired range of items and then drag the group. If the group is selected first and then the mouse released, the individually clicked item is selected when a drag attempt is made on the group.   We are using WPF, but would like to see the Windows Explorer selection functionality. Any thoughts on how to reconcile these two implementations? The most straight forward fix would be a custom control, possibly derived from ListBox/ListView, but this seems like it might be reinventing the wheel. Seems like the WPF controls are not designed properly here.   Thanks.

Retaining the selection color(default blue Color) for the selected items in ListView when focus is l

  
I am having a Listview in a form. I have added items(images) to the Listview. When i select the item(Image) in the listview , the item(image) is selected with Default selection Color(Blue). In the same form i have other form added to its container.When i tried to click on the controls of other form, the default selection color(blue) is changing to Grey color. For the lisview i am using property HideSelection = false. How i could maintain the default selection color(blue) even in focus leave of listview? Can any one please suggest me a solution or give me a piece of code. Thanks in Advance, Kumar

ListView fixed size column headers

  
Hi, I am using a ListView in its 'Detail' view. I have added several columns there and I want to restrict resizing the column width. I couldn't find a ways to do that; is there any easy way to do that? ThanksCJ

Retaining the selection color(default blue Color) for the selected items in ListView when focus is l

  
I am having a Listview in a form. I have added items(images) to the Listview. When i select the item(Image) in the listview , the item(image) is selected with Default selection Color(Blue). In the same form i have other form added to its container.When i tried to click on the controls of other form, the default selection color(blue) is changing to Grey color. For the lisview i am using property HideSelection = false. How i could maintain the default selection color(blue) even in focus leave of listview? Can any one please suggest me a solution or give me a piece of code. Thanks in Advance, mskumar.mcp

how to display a row-specific owner-drawn tooltip in a datagridview?

  
I have an unbound datagridview and an owner-drawn tooltip in C# 2008. I want the draw event to be called on the tooltip. it does not get called. how can i make it get called, or otherwise display an owner-drawn tooltip, row specific? the popup event does get called and resizes the tooltip, but it stops there.

Listview selecteditem binding to textbox causing problems

  

Hi,

 

I have listview and i have binded the listview selected item to a grid's datacontext. The grid contains a text box whose text property is bound to one of the columns in the listview. I have Add, Edit and Delete buttons to manipulate data in the listview.

Problem:

Whenever i change the selected item in the listview the text in the textbox is changing. Since by default the binding is two way if i edit the data in the textbox it is reflectedi in the listview. But upon clicking on the cancel button the textbox value is not reverted back to old value. The list view itemsource is bound to an object of the class BindingListCollectionView

Code in button click event where BindingDetails is object of calss BindingListCollectionView. But this code does not rollback the changes in the textbox.

 

btnCancel_Click(object sender, EventArgs E)
{
  if(IsEdit == true)
  {
     BindingDetails.CancelEdit();                  
          BindingDetails.Refres();<br/>
  }
}

 

I tried the following things.

Trying to get the Text depe

Selection Changed event is not firing for listview

  

Hi,

     In my listview i have two columns, once is check box and another one is normal column. if i select in normal column, listview's selection changed event is fring, but when i select check box(This checkbox is inside the datatemplate) listview's selection changed event is not firing. Can any one tell me how i can achieve it. If you are not understand, please give your email id, i will send my sample application to you.

 

Regards

Udayakumar S


delete multiple selection from ListView

  

Hi All

My ListView has CheckBox column to select ListView items. I don't use SelectionMode="Multiple". I would like to select multiple items and delete them by click button. For that I use a loop

If ListView1.SelectedItems.Count > 0 Then
  For i As Integer = ListView1.SelectedItems.Count - 1 To 0 Step -1
    Me.ListView1.SelectedItems.Remove(i)
  Next
End If

Me.ServiceTableAdapter.Update(Me.TestDataSet.Service)

When I select items and click Delete button nothing was deleted. How fix and get multiple delete items from ListView.

Thanks.


Nested ListView: Parent listview item auto selection on child ListViewitem select

  
 

how can i auto select paraten listview item on selecting child listview item?

<
ListView ItemContainerStyle="{StaticResource myStyle}" Name="lv_list" Margin="5" HorizontalContentAlignment="Stretch">

Can anyone tell me max allowed size of argument of exec('') & any problems if we use exec('') f

  

Can any one tell me max allowed size of argument of exec('') function in sql server ?

moreover, i am using this function to create stored procedure dynamically. so is it advisable to use exec('') for this purpose ?


Problems reconciling design time and runtime size of WPF Canvas

  

Hi, there I am using Visual Studio 2010. I am having trouble with the calculation of the size of my canvas and the positioning of the objects thereupon.

Please consider the following simplest of XAMLs:

<Window x:Class="test01.MainWindow"



 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"



 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"



 Title="MainWindow" Height="350" Width="525">



 <Canvas Margin="0">



 <Label Canvas.Left="505" Canvas.Top="310" Content="Label" Height="28" Name="label1" Background="Blue" />



 <Label Canvas.Left="-36" Canvas.Top="310" Content="Label" Height="28" Name="label2" Background="Red" />



 </Canvas>



</Window>

SEEN:

1) The margins of the canvas are 0

2) at design time I see no part of either the blue label or the red label overlapping my canvas as displayed in Visual Studio

I am unable to explain why at runtime:

1) I see a portion of the blue label.

What is happening here? How can I get a better grip on the real size of my canvas at design time?

 

Edit: OK in case it isn't clear, the problem here is that I wou

WPF ListView Selection

  

I was designing some program and I have problem in getting the selected item name in listview.

Let me explain code.

 

//Following code used to create the ListView in WPF

 

ListView splistview1 = new ListView();

StringReader listview1 = new StringReader(@"<ListView xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' Height='455' HorizontalAlignment='Left' Margin='193,32,0,0' Name='listView1' VerticalAlignment='Top' Width='572'> <ListView.View> <GridView> <GridViewColumn Header='Program Name' Width='200'/> <GridViewColumn Header='Program Path' Width='350'/> </GridView> </ListView.View> </ListView>");

XmlReader reader = XmlReader.Create(listview1);
            splistview1 = (ListView)XamlReader.Load(reader);

 

//Declaring the GridView for ListView

public GridView view = new GridView();
        public GridViewColumn name = new GridViewColumn();
        public GridViewColumn path = new GridViewColumn();

 

//The setting the ListView to GridView

 

public void SetListView()
        {
&nb

Using ASP.NET 3.5's ListView and DataPager Controls: Displaying Data with the ListView

  
Prior to ASP.NET 3.5, developers who needed to display a set of records could choose between the GridView, DataList, and Repeater controls. The GridView provides rich data features, but has a very boxy layout; the DataList and Repeater allow for a more flexible layout, but lack the "point and click" data features found in the GridView, DetailsView, and FormView controls. The ListView bridges the gap between layout flexibility and built-in data features.

This article, the first in a series of articles on the ListView and DataPager controls, looks at the ListView's many available templates and illustrates how to display data. Read on to learn more!

Top .NET Performance Problems and how to avoid them

  
Every time I work with one of our .NET customers to help them with managing their application performance I come across the same problems as seen with other clients before: lots of ADO.NET queries, many hidden exceptions in core or 3rd party .NET libraries, slow 3rd party components, inefficient custom code

Maintain HTML Radio Button Selection Inside GridView After Postback

  
Long time ago I wrote an article about getting the value of the selected RadioButtons inside the GridView control. The code did not addresssed the postback issue which means that the selected radio button was cleared after the postback occurs.
Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend