Similar Threads
1. About catching HDN_ENDTRACK of listview header ?!? - Borland C++ Builder VCL Components
2. Content width (Control width - scroll bar width)
If a scrollbar appeared on the right side of the panel control, How can
I get the real content width?
FlowLayoutPanel
-------------------------------
| | |
| | |
| | |
| | |
| | |
-------------------------------
<----------------------->
3. .Net 2.0 GridView Header width problem - CSharp/C#
4. .Net 2.0 GridView Header fixed width problem
Hi,
In the C#.Net 2.0 webform, I have a GridView GV1.
The question is the width of the GV1's header is not fixed, sometimes if the
item is long,
then the header of that item just shrinks.
How do I fix this problem?
Thanks for help.
Jason
5. clistctrl (columns * width) pixel limits in header ctrl of 32768
6. Capture mouse position during resizing header of ListView ?
Is it possible to obtain without WinAPi ?
Gawel
7. How to change Listview w/different #of col and col header during r - CSharp/C#
8. WPF: Getting correct Width of Control with Adorner
Hi,
I wanted to create a textbox with an depending Label so that I do not have
to add a label each time I add TextBox to a window and tried the following:
public class LabelTextBox : TextBox
{
public static readonly DependencyProperty LabelPositionProperty =
DependencyProperty.Register("LabelPosition", typeof(enAdornerPosition),
typeof(LabelTextBox), new FrameworkPropertyMetadata(enAdornerPosition.Left,
new PropertyChangedCallback(OnLabelPropertyChanged)));
public static readonly DependencyProperty LabelCaptionProperty =
DependencyProperty.Register("LabelCaption", typeof(string),
typeof(LabelTextBox), new FrameworkPropertyMetadata("LabelTextBox", new
PropertyChangedCallback(OnLabelPropertyChanged)));
public static readonly DependencyProperty LabelWidthProperty =
DependencyProperty.Register("LabelWidth", typeof(double),
typeof(LabelTextBox), new FrameworkPropertyMetadata((double)90, new
PropertyChangedCallback(OnLabelPropertyChanged)));
public LabelTextBox()
{ }
public double LabelWidth
{
get { return (double)GetValue(LabelWidthProperty); }
set { SetValue(LabelWidthProperty, value); }
}
public string LabelCaption
{
get { return (string)GetValue(LabelCaptionProperty); }
set { SetValue(LabelCaptionProperty, value); }
}
public enAdornerPosition LabelPosition
{
get {return (enAdornerPosition)GetValue(LabelPositionProperty); }
set {SetValue(LabelPositionProperty, value);}
}
static void OnLabelPropertyChanged(DependencyObject d,
DependencyPropertyChangedEventArgs e)
{
LabelTextBox soBox = (LabelTextBox)d;
AdornerLayer soAdornerLayer = AdornerLayer.GetAdornerLayer(soBox);
if (soAdornerLayer != null)
{
try { foreach (Adorner soAdorner in
soAdornerLayer.GetAdorners(soBox)) { soAdornerLayer.Remove(soAdorner); } }
catch { }
double sdWidth = soBox.LabelWidth;
TextBlock soLabel = new TextBlock() { Text =
soBox.LabelCaption, Width = sdWidth, Foreground = soBox.Foreground };
GenericAdorner soAdoner = new GenericAdorner(soBox, soLabel,
soBox.LabelPosition, sdWidth);
soAdornerLayer.Add(soAdoner);
}
}
}
This still works fine besides the effect that the adorner is not included in
the control width and resizing the control / window is still an adventure
wharf the GUI will look like afterwards.
Is there a way to correct the control width (i tried something like an new
Width Property which returns Textbox.Width+Label.Width, but this did not
work...)?
Does anybody know how to do this?
Thanx,
Chris