|
Windows shortcuts are exposed using the IShellLink interface.
The methods you need are GetPath and GetDescription .
«_Superman_»
|
|
|
|
|
I am making an application that is rendering timeline data. The data is simple - I have an array of Events, Event being a class I've defined with several simple properties.
One of the properties that I'm trying to define is the relationship an individual Event has with other events. Basically, I want some events to be Parent events, and others to be children of those parent events.
How do I define a property that is a pointer to another instance of a class of the same type? In C#, you can't use pointers to classes that contain managed types, so that doesn't seem like an option.
I suppose I could create several arrays, each one representing a parent class, with the parent class being the zeroth element and child classes following the zeroth element, but I was hoping to simplify the data by making one big Array of Events and having each element contain relational data.
Thanks!
|
|
|
|
|
You use a reference. You have already used them, an array of Event is actually an array of references to Event objects.
You can use a parent referene:
public class Event {
public Event Parent { get; set; }
}
Or you can have a list of children:
public class Event {
private List<event> _children = new List<event>();
public List<event> Children { get { return _children; } }
}</event></event></event>
Or you can even have both a parent reference and a childrens list. It depends on how you are going to use it. If you have only a parent reference you have to loop through the array to find a child, and if you only have a childrens list you have to loop through the array and loop through the children of each item to find a parent.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
You should try to implement a composite pattern (which is exactly what the other user suggested), a tree structure for representing hierarchies.
This article contains a complete sample[^]
Calin
modified on Wednesday, February 18, 2009 7:37 PM
|
|
|
|
|
Hello,
I have few UserControls and one Form. In my application I switch the Controls depending on user work. Creating of these Controls is to much time-consuming. I need a method to pre-create this Controls for example in Idle or another Thread. The Idle event blocks the user work and creating Controls in another Thread throws exception "Cross-thread operation not valid".
Do you have some idea how to do it?
Thanks, Vodpik
|
|
|
|
|
Hi,
AFAIK you can't, and IMO you should not even want that. If creating your user controls is time consuming I expect at least one of the following:
1. you did something wrong, making the initialization too slow (e.g. not using SuspendLayout/ResumeLayout when adding lots of items to a listing control)
2. you designed an unrealistic control (too many controls, say 50 or more, in one user control); try changing your design, use listing controls (ListBox, ListView, etc) rather than large numbers of simple controls.
3. you are spending lots of time in getting the data to initialize the controls (e.g. due to networking,
slow web access, slow database access). Start using separate threads to obtain the data, then use Control.InvokeRequired/Control.Invoke to apply the data.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 8:17 AM
|
|
|
|
|
Hey, my name is Yahav and i am a .NET programer (and PHP expert but never mind...)
In my currect program, i am tring to connect to my website SQL server (server type - mySql).
i have downloaded the dll C# lib to do that connect and i have got mySQL "test connection program" who checks the sql connection and give me to edit the program
the link to download: http://dev.mysql.com/downloads/[^]
the problem is when i entering my host address (pearservices.com) or the ip address 62.90.136.206 i got error: "host address {my home address} could not connect to this SQL server."
({my home address} = my home ip address)
but when i entering localhost (mean my own mysql server that i have insalled on my computer) its works very well
someone can explain me why i get this error, and how can i connect to remote server, if this is a problem with my website host, do you have a hosts that give me the abillty to do that?
thanks you very motch, Yahav.
P.S.: Sorry, my engish is not very well.
Gindi Bar Yahav - Web & Software defeloper.
|
|
|
|
|
Just a couple of possibilities... The database server is not visible or not configured to accept connections from outside of its machine (if the webserver resides in the same machine), or from outside the network, or from a network that includes your home IP.
I have never used mySql, but this is what I can think of.
|
|
|
|
|
Firewall issues as well, perhaps?
|
|
|
|
|
Mabye it can be... but do you know a SQL server (I dont mind use mySql/MS Access/SQL Server) that i can connect with it? i searched the net and didnt find... (and its not like the host will say to me "i gives you the abillty to connect from other machine" ^^")
Thanks you very moch for your answers, ill talk today to my host administrator and try to find the problem.
Yahav.
Gindi Bar Yahav - Web & Software defeloper.
|
|
|
|
|
You will have these (firewall ) issues with any piece of DB software, check your port fotwarding
|
|
|
|
|
Hi,
i have a class "user" that implements INotifyPropertyChanged.
with databinding i bind a objekt user1 to textboxes on a winform.
If i change the properties from user1, the textboxes will be updated.
Now i have a function that returns an objekt(user).
user1 = getuser(); -> no changes in the textbox.
with debugging i see, that the setter was not called.
How can i get this done ?
i want to see the returned data in my textboxes.
bye jo
|
|
|
|
|
Did you try rebinding the text box to the new object reference and see if the Notification fires ? You are changing the object reference which your text box was bound to. I suspect the textbox is still bound to the old reference of user1. A rebinding should make it point to the new reference.
|
|
|
|
|
Hi
I need to create a visual graph editor (with drag and drog), something like state diagrams with nodes and arrows, for a specific application.
Any advice on any component\code\framework to support it ?
Thanks for any help.
modified on Wednesday, February 18, 2009 3:45 PM
|
|
|
|
|
There are loads of examples of 'Drawing Board' or UML type apps, both of which use some of the techniques you will need. Try googling for 'UML c#'
or 'drawing board c#'.
An alternative is 'network graph c#', although that does not get such relevant results.
Tell you what, try some for yourself, while you're waiting for someone to come up with a better answer.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi,
I need to build a datagrid dynamically, entirely in c# so no asp tags can be used.
I need my datagrid to contain a textbox in each cell; pre-populated with the corresponding value from the datatable.
My code creates the text box in each cell perfectly BUT every value in the columns is the value of the last cell in that column of the datagrid.
The InstantiateIn method doesn’t seem to be being called for each row and only runs once for the last row. I can’t figure it out....
I pretty inexperienced with c# so any answers would be most appreciated.
Please help.
Thanks,
Jules
//---------------My c# Code Behind file--------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_init(object sender, EventArgs e)
{
GenerateDataGrids();
if (!Page.IsPostBack)
{ }
}
public void GenerateDataGrids()
{
//-- Instantiate the data set and table
DataSet ds = new DataSet();
DataTable dt = ds.Tables.Add();
//-- Add columns to the data table
dt.Columns.Add("ID", typeof(int));
dt.Columns.Add("Book", typeof(string));
dt.Columns.Add("Author", typeof(string));
//-- Add rows to the data table
dt.Rows.Add(1, "1984", "George Orwell");
dt.Rows.Add(2, "Notes from the Underground", "Fydor Dostoyevsky");
dt.Rows.Add(3, "The Outsider", "Albert Camus");
dt.Rows.Add(4, "Post Office", "Charles Buchowski");
dt.Rows.Add(5, "The Chant of Maldoror", "Comte De Lautremont");
DataGrid dg = new DataGrid();
dg.ID = ID;
dg.DataSource = ds;
dg.AutoGenerateColumns = false;
DataTable Workdt = new DataTable();
Workdt = ds.Tables[0];
for (int i = 0; i <= dt.Columns.Count - 1; i++)
{
// Creating Template Column
TemplateColumn tc = new TemplateColumn();
string columnName = dt.Columns[i].ColumnName;
tc.HeaderTemplate = new DataGridTemplate(ListItemType.Header, columnName);
for (int j = 1; j <= dt.Rows.Count - 1; j++)
{
string RowCallName = dt.Rows[j][i].ToString();
tc.ItemTemplate = new DataGridTemplate(ListItemType.EditItem, RowCallName);
}
dg.Columns.Add(tc);
}
dg.DataBind();
form1.Controls.Add(dg);
}
}
public class DataGridTemplate : ITemplate
{
ListItemType templateType;
string columnName;
public DataGridTemplate(ListItemType type, string colname)
{
templateType = type;
columnName = colname;
}
public void InstantiateIn(System.Web.UI.Control container)
{
Literal lc = new Literal();
switch (templateType)
{
case ListItemType.Header:
lc.Text = "" + columnName + "";
container.Controls.Add(lc);
break;
case ListItemType.Item:
lc.Text = "Item " + columnName;
container.Controls.Add(lc);
break;
case ListItemType.EditItem:
TextBox tb = new TextBox();
tb.Text = columnName;
container.Controls.Add(tb);
break;
case ListItemType.Footer:
lc.Text = "" + columnName + "";
container.Controls.Add(lc);
break;
}
}
}
]]>
]]>
<title>
|
|
|
|
|
I spotted one bug in your code:
you are looping through columns, and for each column you are looping the rows, so tc.ItemTemplate = new DataGridTemplate(ListItemType.EditItem, RowCallName); gets updated for each row, but it is used only one time, after exiting the loop, so last value of tc.ItemTemplate is the last row value.
Calin
|
|
|
|
|
You cannot do this using tc.ItemTemplate , you are not using it correctly. ItemTemplate is used to specify the template of a column, so you cannot specify 5 templates (for 5 rows) - for the same column.
Anyway, the colums templates are defined ok, but the binding is wrong.
Calin
|
|
|
|
|
Hello,
I am trying to initialize a jagged array as shown below. "Screen2 button IDs" and "Screen3 button IDs" arrays are a replica of the "Default screen button IDs" array. I was hoping to find a way where I can declare and initialize a 1-dimensional array similar to the "Default screen button IDs" one then use this array in my jagged array initialization. This will help me preserve some space and make the array look shorter. Any advice on how to achieve this?
Thanks,
<pre>BUTTON_ID[][] CONTEXT_MENU_LIST = new BUTTON_ID[][]
{
//System off
new BUTTON_ID[]{BUTTON_ID.INACTIVE, BUTTON_ID.INACTIVE, BUTTON_ID.INACTIVE,
BUTTON_ID.INACTIVE, BUTTON_ID.INACTIVE, BUTTON_ID.INACTIVE,
BUTTON_ID.INACTIVE, BUTTON_ID.INACTIVE, BUTTON_ID.INACTIVE,
BUTTON_ID.INACTIVE, BUTTON_ID.INACTIVE, BUTTON_ID.INACTIVE,
BUTTON_ID.INACTIVE},
//Default Screen button IDs
new BUTTON_ID[] {BUTTON_ID.DEFAULT, BUTTON_ID.EXAMINE, BUTTON_ID.CLIP,
BUTTON_ID.GAIN, BUTTON_ID.PAGE1, BUTTON_ID.FROZEN,
BUTTON_ID.SAVE, BUTTON_ID.PAGE2, BUTTON_ID.INACTIVE,
BUTTON_ID.DECREASE_LENGTH, BUTTON_ID.INCREASE_LENGTH,
BUTTON_ID.DECREASE_WIDTH, BUTTON_ID.INCREASE_WIDTH},
//Clip View Screen
new BUTTON_ID[] {BUTTON_ID.INACTIVE, BUTTON_ID.PAGE1, BUTTON_ID.FROZEN,
BUTTON_ID.AUTO_GAIN, BUTTON_ID.CLIP, BUTTON_ID.INACTIVE,
BUTTON_ID.SAVE, BUTTON_ID.PAGE2, BUTTON_ID.INACTIVE,
BUTTON_ID.INACTIVE, BUTTON_ID.INACTIVE,BUTTON_ID.INACTIVE,
BUTTON_ID.INACTIVE}
//Screen2 button IDs
new BUTTON_ID[] {BUTTON_ID.DEFAULT, BUTTON_ID.EXAMINE, BUTTON_ID.CLIP,
BUTTON_ID.GAIN, BUTTON_ID.PAGE1, BUTTON_ID.FROZEN,
BUTTON_ID.SAVE, BUTTON_ID.PAGE2, BUTTON_ID.INACTIVE,
BUTTON_ID.DECREASE_LENGTH, BUTTON_ID.INCREASE_LENGTH,
BUTTON_ID.DECREASE_WIDTH, BUTTON_ID.INCREASE_WIDTH}
//Screen3 button IDs
new BUTTON_ID[] {BUTTON_ID.DEFAULT, BUTTON_ID.EXAMINE, BUTTON_ID.CLIP,
BUTTON_ID.GAIN, BUTTON_ID.PAGE1, BUTTON_ID.FROZEN,
BUTTON_ID.SAVE, BUTTON_ID.PAGE2, BUTTON_ID.INACTIVE,
BUTTON_ID.DECREASE_LENGTH, BUTTON_ID.INCREASE_LENGTH,
BUTTON_ID.DECREASE_WIDTH, BUTTON_ID.INCREASE_WIDTH}
};</pre>
|
|
|
|
|
Just place it in a temporary variable first?
warning: untested
BUTTON_ID[] defaultids = new BUTTON_ID[] {BUTTON_ID.DEFAULT, BUTTON_ID.EXAMINE, BUTTON_ID.CLIP,
BUTTON_ID.GAIN, BUTTON_ID.PAGE1, BUTTON_ID.FROZEN,
BUTTON_ID.SAVE, BUTTON_ID.PAGE2, BUTTON_ID.INACTIVE,
BUTTON_ID.DECREASE_LENGTH, BUTTON_ID.INCREASE_LENGTH,
BUTTON_ID.DECREASE_WIDTH, BUTTON_ID.INCREASE_WIDTH};
BUTTON_ID[][] CONTEXT_MENU_LIST = new BUTTON_ID[][]
{
new BUTTON_ID[]{BUTTON_ID.INACTIVE, BUTTON_ID.INACTIVE, BUTTON_ID.INACTIVE,
BUTTON_ID.INACTIVE, BUTTON_ID.INACTIVE, BUTTON_ID.INACTIVE,
BUTTON_ID.INACTIVE, BUTTON_ID.INACTIVE, BUTTON_ID.INACTIVE,
BUTTON_ID.INACTIVE, BUTTON_ID.INACTIVE, BUTTON_ID.INACTIVE,
BUTTON_ID.INACTIVE},
defaultids,
new BUTTON_ID[] {BUTTON_ID.INACTIVE, BUTTON_ID.PAGE1, BUTTON_ID.FROZEN,
BUTTON_ID.AUTO_GAIN, BUTTON_ID.CLIP, BUTTON_ID.INACTIVE,
BUTTON_ID.SAVE, BUTTON_ID.PAGE2, BUTTON_ID.INACTIVE,
BUTTON_ID.INACTIVE, BUTTON_ID.INACTIVE,BUTTON_ID.INACTIVE,
BUTTON_ID.INACTIVE},
defaultids,
defaultids
};
|
|
|
|
|
I already tried that and got the following error message: "A field initializer cannot reference the non-static field, method, or property"
|
|
|
|
|
Make the temporary thing static?
|
|
|
|
|
harold aptroot wrote: temporary thing
... the latest buzzwords always confuse me
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Ok better idea: initialize it in the constructor.
|
|
|
|
|
That works like a charm. Would you please explain to me what did the static keyword change in this case?
Appreciated,
|
|
|
|
|