|
Bending the PropertyGrid to Your Will[^] by Tony Allowatt. It's an excellent article, well worth reading.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
I spent some time reading the article but unfortunately it didn't have what I needed with respect to custom controls. However, thanks to one of the "Other Article" links at the bottom of that article, I ran into the solution from one[^] of the comments made on it.
Thanks for pointing me in the right direction.
Regards,
Alvaro
If you want to get to the top, prepare to kiss a lot of bottom. -- despair.com
|
|
|
|
|
Alvaro Mendez wrote:
I'm now creating a custom control myself for which I want add a property with sub-properties. How is that done? Is there an example I can look at somewhere?
I really appreciate your help,
This is done with attributes, here is an example where using the same Category attribute's name will cause the Color property and the String property to be grouped under Options (note each property has it's own Description ). Hope this helps.
internal class Properties
{
[Category("Options"),
Description("The color of the header on main form at top.")]
public Color Color
{
get{return _color;}
set{_color = value;}
}
[Category("Options"),
Description("Some string used in the app.")]]
public String String
{
get{return _s;}
set{_s = value;}
}
private Color _color;
private String _s;
}
-Nick Parker
|
|
|
|
|
I don't think so. You didn't understand the question
And I don't know the answer!
Don't forget, that's Persian Gulf not Arabian gulf!
|
|
|
|
|
Meisi wrote:
You didn't understand the question
Ummm, yes I did.
Meisi wrote:
And I don't know the answer!
Read my previous post again.
-Nick Parker
|
|
|
|
|
Meisi wrote:
You didn't understand the question
Nick Parker wrote:
Ummm, yes I did.
Why didn't you answer it, then...;)
|
|
|
|
|
Arjan Einbu wrote:
Why didn't you answer it, then.
Oppps, my mistake. Guess I need some
-Nick Parker
|
|
|
|
|
Nick Parker wrote:
Ummm, yes I did.
Actually no Nick. I was referring to Sub-Properties not Categories. Take a look at the Font property. It's already under the "Appearance" category, but it also has its own set of properties.
Thanks anyway, and here's[^] the solution in case you're interested.
Regards,
Alvaro
If you want to get to the top, prepare to kiss a lot of bottom. -- despair.com
|
|
|
|
|
Alvaro Mendez wrote:
Actually no Nick. I was referring to Sub-Properties not Categories. Take a look at the Font property. It's already under the "Appearance" category, but it also has its own set of properties.
Again, opps, sorry I did mis-understand what you initially meant.
-Nick Parker
|
|
|
|
|
Nick Parker wrote:
I did mis-understand
hehe! you see? you didn't corrctly understand the question!
Don't forget, that's Persian Gulf not Arabian gulf!
|
|
|
|
|
Meisi wrote:
hehe! you see? you didn't corrctly understand the question!
That's ok, I do now.
-Nick Parker
|
|
|
|
|
|
i dont have vs.net on this machine to try it out, but have you noticed that all of the properties that have the sub properties, are objects that have properties, e.g. Size has the properties Width and Height in it. Try grouping the properties that you want grouped in the designer into a seperate object, and use that as a property, and it may do the trick, but i dont know.
Another Post by NnamdiOnyeyiri l Website
|
|
|
|
|
Thanks Nnamdi. You're correct that these properties need to be grouped into a separate class. But that alone does not do it. Check out the solution[^]. It's amazingly simple.
Regards,
Alvaro
If you want to get to the top, prepare to kiss a lot of bottom. -- despair.com
|
|
|
|
|
I found the solution in this[^] comment from Gerd Klevesaat.
Regards,
Alvaro
If you want to get to the top, prepare to kiss a lot of bottom. -- despair.com
|
|
|
|
|
Hi anyone have a short code snippet of adding a sub item in the detail view, i direly need this
and the below doesnt work
listView1.View = View.Details;
// Allow the user to edit item text.
listView1.LabelEdit = true;
// Allow the user to rearrange columns.
listView1.AllowColumnReorder = true;
// Display check boxes.
listView1.CheckBoxes = true;
// Select the item and subitems when selection is made.
listView1.FullRowSelect = true;
// Display grid lines.
listView1.GridLines = true;
// Sort the items in the list in ascending order.
listView1.Sorting = SortOrder.Ascending;
// Create three items and three sets of subitems for each item.
ListViewItem item1 = new ListViewItem("item1",0);
// Place a check mark next to the item.
item1.Checked = true;
item1.SubItems.Add("1");
item1.SubItems.Add("2");
item1.SubItems.Add("3");
ListViewItem item2 = new ListViewItem("item2",1);
item2.SubItems.Add("4");
item2.SubItems.Add("5");
item2.SubItems.Add("6");
ListViewItem item3 = new ListViewItem("item3",0);
// Place a check mark next to the item.
item3.Checked = true;
item3.SubItems.Add("7");
item3.SubItems.Add("8");
item3.SubItems.Add("9");
// Create columns for the items and subitems.
listView1.Columns.Add("Item Column", 100, HorizontalAlignment.Left);
listView1.Columns.Add("Column 2", 100, HorizontalAlignment.Left);
listView1.Columns.Add("Column 3", 100, HorizontalAlignment.Left);
listView1.Columns.Add("Column 4", 100, HorizontalAlignment.Center);
//Add the items to the ListView.
listView1.Items.AddRange(new ListViewItem[]{item1,item2,item3});
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
straight from msdn....
ListViewItem listViewItem1 = new ListViewItem(new string[] {"Banana","a","b","c"}, -1, Color.Empty, Color.Yellow, null);<br />
ListViewItem listViewItem2 = new ListViewItem(new string[] {"Cherry","v","g","t"}, -1, Color.Empty, Color.Red, new Font("Microsoft Sans Serif", 8.25F, FontStyle.Regular, GraphicsUnit.Point, ((System.Byte)(0))));<br />
ListViewItem listViewItem3 = new ListViewItem(new string[] {"Apple","h","j","n"}, -1, Color.Empty, Color.Lime, null);<br />
ListViewItem listViewItem4 = new ListViewItem(new string[] {"Pear","y","u","i"}, -1, Color.Empty, Color.FromArgb(((System.Byte)(192)), ((System.Byte)(128)), ((System.Byte)(156))), null);<br />
<br />
this.listView1 = new ListView();<br />
<br />
this.listView1.Sorting = SortOrder.None;<br />
this.listView1.View = View.Details;<br />
this.listView1.Columns.Add(new ColumnHeader());<br />
this.listView1.Columns[0].Text = "Column 1";<br />
this.listView1.Columns[0].Width = 100;<br />
listView1.Columns.Add(new ColumnHeader());<br />
listView1.Columns[1].Text="Column 2";<br />
listView1.Columns.Add(new ColumnHeader());<br />
listView1.Columns[2].Text="Column 3";<br />
listView1.Columns.Add(new ColumnHeader());<br />
listView1.Columns[3].Text="Column 4";<br />
this.SuspendLayout();<br />
this.listView1.Items.AddRange(new ListViewItem[] {listViewItem1,<br />
listViewItem2,<br />
listViewItem3,<br />
listViewItem4});<br />
this.listView1.Location = new Point(10, 10);<br />
this.listView1.Name = "listView1";<br />
this.listView1.Size = new Size(300, 100);<br />
this.listView1.TabIndex = 0;<br />
this.listView1.LabelEdit = true;<br />
this.listView1.ColumnClick += new ColumnClickEventHandler(ColumnClick);<br />
<br />
this.AutoScaleBaseSize = new Size(5, 13);<br />
this.ClientSize = new Size(400, 400);<br />
this.Controls.AddRange(new Control[] {this.listView1});<br />
this.Name = "ListViewSortForm";<br />
this.Text = "Sorted ListView Control";<br />
this.ResumeLayout(false);<br />
}<br />
hope it helps.
Csharp™ the coder formally known as dynamic
Me.twins.duedate = DateTime.Now.AddDays(+16).ToLongDateString Me.Birthday = DirectCast(Me.twins.DueDate, DateAndTime.SameDay)
|
|
|
|
|
Well actually the code worked, i had this odd idea there would be additional lines created but no i was wrong. I guess I mus use a tree view which I did not want to do.
nick
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
i've seen lots of links to the syncrofusion site, but it still doesn't clear up the column width problem.
i've added a tablestyle to my datagrid, .. and then i've added grid column styles to my table style.
i populate my datagrid like this:
<br />
dataGrid1.SetDataBinding(ds,"Contacts");<br />
but how do i bind the tablestyle / column styles to this datagrid?
i thought that is what i was doing in the gui of VS, but it does not pick up the widths i set.
can someone clear this up any?
|
|
|
|
|
myDataGrid.DataSource = myTable;
do a clear on the tables styles object before adding it, its easier.
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
you have to set the Mapping Name of the tablestyle to that of the database table you want this style to apply to.. For exampe "Mapping Name = Contacts".. Also apply the mapping name of each columnstyle to map to the corresping column of your database table..
Freelance Developer... Constantly looking for Gigs.
|
|
|
|
|
but by his example setting the mappings still wont work
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
How do you set/change Environment Variables with c#??
I can read them but, how can I change them?
Thanks,
Jonathan
|
|
|
|
|
the .NET framework doesnt have this ability, so you will have to use MSDN to find the API's used to get/set the variables, then import the functions.
Another Post by NnamdiOnyeyiri l Website
|
|
|
|
|
As a follow up to Nnamdi's comment, you can use the API SetEnvironmentVariable, but that only places the variable in the process's local environment. If you want the change to be system-wide (permanent), you need to modify the registry.
Take a look at these two keys in your registry:
System variables: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
User variables: HKEY_CURRENT_USER\Environment
Regards,
Alvaro
If you want to get to the top, prepare to kiss a lot of bottom. -- despair.com
|
|
|
|
|