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

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

How do I get the ordinal position of a control without knowing, and more importantly, not needing to

Posted By:      Posted Date: September 12, 2010    Points: 0   Category :WPF
Hello, How do I get the ordinal position of a control without knowing, and more importantly, not needing to know it's parent type? For example, this XMAL: <Parent of unknown type>      <Control Name="Control_1" />      <Control Name="Control_2" />      <Control Name="Control_3" />      <Control Name="Control_4" /> </Parent of unknown type> How do I get "Control_3"s ordinal position within its parent control? I know that I can do this:     UIElement p = (UIElement)Control_3.Parent; or even:     FrameworkElement p = (FrameworkElement)Control_3.Parent; but neither of those allow:     int i = p.Children.IndexOf(Control_3); nor     int i = p.Items.IndexOf(Control_3); If the parent is a StackPanel, I can do:     StackPanel p = (StackPanel)Control_3.Parent; and then I can do:     int i = p.Children.IndexOf(Control_3); I really do not want to have to cast the parent to a specific type, that would be a pain since there several types that could have children or items. Regards, Robert

View Complete Post

More Related Resource Links

How to position one control relative to another one even after resizing windows?


I used following Jquery code trying to make image close to a table. It worked fine after first load, but the position changed after window is resized. Any ideas? thanks

$(document).ready(function() {
            var pos = $("#mytable").offset();
            var width = $("#mytable").width();
            var left = pos.left + width + 20;
            var top = pos.top + 200;
                position: 'absolute',
                zIndex: 5000,
                left: left,
                top: top

Knowing the event occured in user control in current page




      My web application has user control which uses third party controls called Devexpress controls. The user control is a menu  and is part of the Master page. It is placed there because this needs to be available in all the pages. My user controls raises a even on item clicked. Now, My question is that Is there any way to know that the event has occurred in page_load of the current page in which I am in?

changing the control position


How can i change control position in aspx page at runtime Is it possible through xml / xslt  files
with out re-depoying the code.Any sample code / links
Please help me out 

Get Control screen position from a MVVM View Model (not using CodeBehind in the control)


Hi, I am using a MVVM pattern for a WPF UserControl. I need to be able to position a dialog over the top of the control, so I need the top left screen coords for the control.

IF, I was to use code behind, the following seems to do the job..

 private void UserControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
   Point controlPos = PointToScreen(new Point(0, 0));

The controlPos above seems to give the correct result. However, is there anyway of doing this without having to use any code behind in the actual control (eg have the code purley perhaps in the View model class, of have something in the Controls XAML?

Thanks in advance for any help



is there any way to know the position of my cursor - in TextBox control ?


i have in my C# (WinForms) program TextBox control

if i have this text in: `abcd efg hijklmnop`

and i stand with my cursor between `c` and `d`  = position 3

or i stand with my cursor between `h` and `i`  = position 10

how to get this position ?

thank's in advance

Use the LookupField control without knowing the ListId?

I have a feature that creates a list and publishes a webpart.  The webpart has a LookupField webcontrol on it that needs to point to the List that the feature is creating.  How can I do this without programmatically creating the LookupField webcontrol?  Is that the only way?

Adding Dynamic Rows in ASP.NET GridView Control with TextBoxes and with Delete functionality

In my previous examples, I have demonstrated on how to add dynamic rows in GridView control with TextBoxes and how to save the values into the database. Now, seems that most of the developers are asking if how to add a delete functionality with it. So in this example, I'm going to show on how to delete a certain row in the dynamic GridView with TextBoxes.

Accessing the different controls inside a GridView control

how we can access a particular control which resides inside a GridView control. In this article I will show you how you can access different controls inside a GridView control. We will see how we can access a TextBox control, a DropDownList control and a ListBox control. If you are working with ASP.NET 1.X then you might want to check out my article Accessing Different Controls Inside a DataGrid.

In-Depth look at the GridView Control

In the last article we looked at few of the new controls available in Asp.net 2.0. We also talked about Grid View Control which has replaced the Asp.net 1.1 DataGrid control for good. In this article we will examine more features of the Grid View control. In this article we will see some of the common operations that can be performed using the GridView control. Apart from these operations there are many more functions that can be performed on the control and which we will see in the later articles

ASP.NET repeater control - databind with style

even used the inline editing features, which I at the time thought was the coolest way possible to write ASP.NET code ( I managed to write code to hide all other rows and only show the current one - the row being edited). With a nice looking EditTemplate it looked indeed very slick but it really turned into giant and hard to manage code behind files.

Creating Paging for a Repeater Control

A common question is "How do I implement paging within a Repeater?" Although the beauty of the Repeater control is its flexibility, you're on your own for building most functions. ASP.NET 2.0 has included some new controls that provide paging, as does the DataGrid in ASP.NET 1.1. However, this tip shows you how to roll your own paging for a simple data viewer.

Using TemplateFields in the GridView Control

The GridView is composed of a set of fields that indicate what properties from the DataSource are to be included in the rendered output along with how the data will be displayed. The simplest field type is the BoundField, which displays a data value as text. Other field types display the data using alternate HTML elements. The CheckBoxField, for example, renders as a checkbox whose checked state depends on the value of a specified data field; the ImageField renders an image whose image source is based upon a specified data field. Hyperlinks and buttons whose state depends on an underlying data field value can be rendered using the HyperLinkField and ButtonField field types.

How To Add calendar control inside a GridView

This article show hot to add calendar control inside a GridView with code in c#

Using ATLAS PopUp Control with Calendar inside the GridView Control

In this video tutorial Mohammad demonstrates how you can access the Calendar control which is displayed using the ATLAS PopUp control inside the GridView control.

GridView control to show master-child or master-slave data, written in c#, asp.net

I previously made a master slave datagrid using Visual Studio 2003 .Net (original article) that would allow users to show data to clients using collapse and expand features. These features however did not carry over to gridview for many users. This tutorial will explaing how to create a collapsable/expandable gridview in frameworks 2.0 and higher

Easily manipulate data with the GridView control in ASP.NET 2.0

Last week, I introduced ASP.NET 2.0's GridView data control and covered the basics of using it. This week, I go a step further by going into the details of working with the data contained in the control. This includes viewing, editing, and deleting data. Thankfully, the GridView control makes it easy to utilize these features. Before diving into these topics, I begin with an examination of the different field types supported by the GridView control.

GridView Multiple Filter AJAX Control

This AJAX control enables the user to filter data within any column inside a GridView. The user can add multiple filters and can delete existing ones too.
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