salut tous le monde,
je développe une WindowsContrl library dans laquelle je crée des contoles personnalisés, actuellement je suis entrain de créer une liste box mais j ai un probleme dans la redefinition la proprieté width voila mon code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
 
using System;
using System.Text .RegularExpressions ;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Drawing;
using System.Collections;
using System.Collections.Specialized;
using System.Globalization;
//using System.Windows.Forms;
 
namespace WindowsControl
{
		[DefaultProperty("Text"), ToolboxData("<{0}:listField runat=\"server\"></{0}:listField>")]
	[ValidationPropertyAttribute("SelectedItem")] 
	public class listField : ListBox
 {
	 private bool _isReadOnly = true;
	 private bool _autoPostBack=false;
	 private bool _isEnable=true;
	 private int _rows=4;
	 private Unit _Width=150;
 
	 public virtual bool ReadOnly//override c'est pour redéfinir qelq chose
	 {
		 get { return _isReadOnly; }
		 set { _isReadOnly = value; }
	 }
	 public override bool  Enabled
	 {
		 get { return _isEnable; }
		 set { _isEnable = value; }
	 }
 
	 public override bool  AutoPostBack
	 {
		 get { return _autoPostBack; }
		 set { _autoPostBack = value; }
	 }
 
	 public override int Rows
	 {
		 get { return _rows; }
		 set { _rows = value; }
	 }
	 public override Unit Width
	 {
		 get{return _Width;}
		 set{_Width = value;}
	 }
	 [DefaultValue (typeof (ListSelectionMode), "Multiple")]
 
	 public override ListSelectionMode SelectionMode
	 {
		 get
		 {
			 object o = ViewState ["SelectionMode"];
			 return (o == null) ? ListSelectionMode.Multiple : (ListSelectionMode) o;
		 }
		 set
		 {
			 //if (!Enum.IsDefined (typeof (ListSelectionMode), value))
				 //throw new ArgumentOutOfRangeException ("value", "Only valid enumeration members are allowed");
			 ViewState ["SelectionMode"] = value;
		 }
	 }
 
			private void Control_Load(object sender, System.EventArgs e)
			{
 
 
			}
			private void InitializeComponent()
			{
				this.Load += new System.EventHandler(this.Control_Load);
			}
 
 }
si vous pouvez m aider pour bien redefinir la propriété width , et merci.