|
Hello there CP experts,
I don't really know what its called but I would like to create my own common tasks editor for my control.
By common tasks editor I mean the square window you can open by clicking the small button with the arrow pointing right, which is located in the upper right corner of the controls.
This window's title is always in the form of "<Control Type> Tasks" (e.g. "ListView Tasks").
I've inherited the ComboBox control in order to create an ImageCombo control.
What I want now is to create my own tasks editor and replace the old one that ComboBox defines...
Help...??
Thanks in advance,
Shy.
|
|
|
|
|
I have wrote an article that should be perfect for your situation, if you are talking about the design-time smart tags of VS. Targeting Design-Time Events of User Controls[^] gives you information to add smart tags during design-time to your custom controls and allows you to add interactivity to the design-time experience.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
Thanks! Looks really neat!
Regards,
Shy.
|
|
|
|
|
Hi,
i use DataSet method (writexml) to create an xml file.
in the table i have only "2005-10-3" and in the xml file
"2005-10-3:T00:00:00-2:00"
How to change this???????????
To many questions ? No, not enough answers!!!
|
|
|
|
|
I'm not sure, but I don't think you can actually change it because that would have to involve editing the WriteXML method, which you can't.
Is parsing it when you load the XML file again a solution to your problem?
You can use datatime.ToShortDateTime() and other methods.
public object BufferOverFlow<br />
{<br />
__get { return BufferOverFlow; }<br />
__set { BufferOverFlow = value; }<br />
}
|
|
|
|
|
I must create the xml in one fixed format.
I have create one bull s...t
I have create another table with string fields and with this i can write the exact format but it is not a good ideea. This s...t works but the method is ..... not for the coders.
<code>
DataRow row2 = tr.NewRow();
object[] vct = dataTemp.Rows[0].ItemArray;
for (int k = 0; k < vct.Length;k++ )
{
MessageBox.Show(vct[k].GetType().ToString());
if (vct[k].GetType().ToString() == "System.DateTime")
{
DateTime dtime = new DateTime();
dtime = Convert.ToDateTime(vct[k]);
row2[k] = dtime.ToString("yyyy-MM-dd");
}
else
row2[k] = vct[k].ToString(); </code>
|
|
|
|
|
1. you should use
for (int k = 0; k < vct.Length -1; k++)
2. try to use dtime.ToShortDateString or if you really need custom formatting I always prefer things like this:
dtime.Year + "-" + dtime.Month + "-" + dtime.Day
public object BufferOverFlow<br />
{<br />
__get { return BufferOverFlow; }<br />
__set { BufferOverFlow = value; }<br />
}
|
|
|
|
|
My method works good but is not what i want!! I WANT TO KNOW IF IT IS POSIBILE TO CHANGE THE FORMAT OF ONE DATETIME (type) FROM ONE TABLE:
EX:
if i have DataTable dt["Data"]="2004-10-2";
when i write dt.WriteXml(...);
i want to obtain:
<<data>2004-10-2</data>
and NOOOOOOOOOOO this:
<data>2004-10-2:T00:00:00:.....</data>
|
|
|
|
|
I don't think it's that easy.
What I would do is derive the DateTime class and try to override the Deserialize or ToString() method, because I think that's what WriteXml uses.
I just discovered that deriving DateTime is not possible, as it is sealed.
Try this instead...
<br />
class MyOwnDateTime <br />
{<br />
public int year;<br />
public int month;<br />
public int day;<br />
<br />
public MyOwnDateTime(DateTime date)<br />
{<br />
year = date.Year;<br />
month = date.Month;<br />
day = date.Day;<br />
}<br />
<br />
public override string ToString()<br />
{<br />
return year + "-" + month + "-" + day;<br />
}<br />
}<br />
By using a custom datatype, you might achieve the results you want.
Hope this helps...
public object BufferOverFlow<br />
{<br />
__get { return BufferOverFlow; }<br />
__set { BufferOverFlow = value; }<br />
}
|
|
|
|
|
Hi everybody,
I need to constitute a ListBox array (like listBox[i]) , which the user can add various number of listboxes to form in runtime. Is there any way to do that?
Thanks...
memix
|
|
|
|
|
You simply have to declare something like:
<br />
ListBox []lbArray = new ListBox[100];<br />
<br />
for (int i = 0 ; i < lbArray.length ; i++)<br />
{<br />
lbArray[i] = new ListBox();<br />
}<br />
Hope it helps
Do your best to be the best
|
|
|
|
|
if you're using .net 2.0 i'd be tempted to use Collection<listbox> instead. That way you don't need to know how many listboxes the user is likely to add.
HTH
Russ
|
|
|
|
|
What you would normally do, is instantiate your listbox and then add it into the form Controls collection (or relevant child control if hosting in a groupbox or something). To see how this works, take a look at what you get when you add a listbox to a form in Visual Studio.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
It will better to use sortedList or hashTable to store the list box with the key as List box name.
SortedList listBoxItems = new SortedList();
foreach(ListBox listBox )
{
listBoxItems.Add(listBox);
}
My small attempt...
|
|
|
|
|
But how does the listbox get added to the form? The OP talked about user created listboxes and displaying them on a form.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Dear friends,
Thanks for all of you, I succeed it, it works what I want,
at the end my solution is here:
public int numberOfListBoxes =0;
ListBox[] lbArray;
private void button1_Click(object sender, EventArgs e)
{
numberOfListBoxes = Convert.ToInt32(textBox1.Text);
lbArray = new ListBox[numberOfListBoxes];
int i;
int listBoxDistances=100;
for (i = 0; i < numberOfListBoxes; i++)
{
lbArray[i] = new ListBox();
this.lbArray[i].Location = new System.Drawing.Point(100+(i*listBoxDistances), 200);
this.lbArray[i].Name = "lbArray"+"["+i+"]";
this.lbArray[i].Size = new System.Drawing.Size(57, 100);
this.lbArray[i].TabIndex = 2;
this.lbArray[i].Text = "lb";
this.Controls.Add( lbArray[i]);
}
memix
|
|
|
|
|
Can I add a small performance enhancement here? Don't add your listboxes to the control collection in each iteration. Instead, use Controls.AddRange to add the entire collection of listboxes.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi,
I have a placed a TreeView control in my application.
On the after select event i wanted to know which element was selected to do something with it:
<br />
private void tvLibrary_AfterSelect(object sender, TreeViewEventArgs e)<br />
{<br />
TreeView tree = (TreeView) sender;<br />
MessageBox.Show(node.Name)); <br />
} <br />
The thing is that the message box comes blank.
What am i doing wrong?
Thx,
Nuno
|
|
|
|
|
hi
discover the e parameter e.g e.Node.Text or e.Node.Tag
The e.Node is the selected Node
regards
|
|
|
|
|
ohhh
Of course!!
Thx,
Nuno
|
|
|
|
|
Hi again,
Now that i have the name of the node i want to see if its a directory or if its just a file.
A directory has more nodes below, and a file doesnt.
What i did was:
<br />
TreeNode next = null;<br />
next = node.NextNode;<br />
<br />
if (next!=null)<br />
{<br />
MessageBox.Show(node.Text);<br />
}<br />
else<br />
{<br />
MessageBox.Show("Doesnt have");<br />
}<br />
But this has a strange behaviour...
When i click a file, it shows a message box with the name of the file.
When i click in a folder, it shows a message saying i "Doesnt have"
Once again... what am i doin wrong?
Thank you very much.
Nuno
|
|
|
|
|
the behaviour isn't so strange.
When I looked up the .NextNode method in the object browser, it said:
"Summary: Gets the next sibling tree node."
MSDN Treenode[^]
Siblings are on the same level as the current one, it is not a child.
instead of
if (node.NextNode != null)
you should check
if (node.Nodes != null) ...<br />
if (node.FirstNode != null) ...
or
if (node.Nodes.Count > 0) ...
(I'm not sure whether it is initiallized when it's zero. Probably safest to use
if (node.Nodes != null && node.Nodes.Count > 0)
I hope this will get you the desired functionality.
|
|
|
|
|
Hi,
I have just noticed that i dont have a consistent Tree.
I want to implement a tree to explore a directory which is going to be a library of files.
This is the code i have for it to be filled:
<br />
<br />
if (!Directory.Exists("Library"))<br />
{<br />
Directory.CreateDirectory("Library\Flash");<br />
Directory.CreateDirectory("Library\Image");<br />
Directory.CreateDirectory("Library\Movie");<br />
Directory.CreateDirectory("Library\Url");<br />
}<br />
<br />
private void initializeTree()<br />
{<br />
tvLibrary.Nodes.Clear();<br />
tvLibrary.Nodes.Add(new TreeNode("Library"));<br />
TreeNode tNode = new TreeNode();<br />
tNode = tvLibrary.Nodes[0];<br />
<br />
populateTree(Application.StartupPath + @"\Library", tNode, 0);<br />
tvLibrary.ExpandAll();<br />
}<br />
<br />
private void populateTree(string root, TreeNode inTreeNode, int level)<br />
{<br />
TreeNode tNode;<br />
<br />
try<br />
{<br />
if (root.CompareTo("") == 0)<br />
return;<br />
<br />
System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(root);<br />
<br />
DirectoryInfo[] dirs = dir.GetDirectories();
FileInfo[] files = dir.GetFiles();
<br />
foreach (System.IO.DirectoryInfo di in dirs)<br />
{<br />
inTreeNode.Nodes.Add(new TreeNode(di.Name));<br />
<br />
tNode = inTreeNode.Nodes[level];<br />
populateTree(root + @"\" + di.Name, tNode, level + 1);<br />
}<br />
<br />
foreach (System.IO.FileInfo fi in files)<br />
{<br />
inTreeNode.Nodes.Add(new TreeNode(fi.Name));<br />
}<br />
}<br />
catch (System.Exception err)<br />
{<br />
MessageBox.Show("Error: " + err.Message);<br />
}<br />
}<br />
I detected two problems. If i have files in the Images directory they appear normally, under Images sub folder inside the main node, Library.
However, if i have files under Movies, or Urls folders, those files appear under the Images sub folder.
The other problem is that if create a folder inside the Images folder, a error happens, which i think its about the level depthness.
I tried to understand this tree concept but its quite strange.
Can someone try to expalin me what is going on?
Thx,
Nuno
|
|
|
|
|
I think one of your problems lies here:
tNode = inTreeNode.Nodes[level];
I looked into it (yes I have too much time) and that's the only line I couldn't really get. There is no relation between the level variable, and the position of the desired node in the nodes Array.
You should instead use this, I think (works here, with c:\temp dir):
<br />
foreach (System.IO.DirectoryInfo di in dirs)<br />
{<br />
TreeNode tn = new TreeNode(di.Name);<br />
<br />
<br />
populateTree(root + @"\" + di.Name, tn, level + 1);<br />
<br />
inTreeNode.Nodes.Add(tn);<br />
}<br />
Also, I wouldn't use recursion, because it makes your code needlessly complicated
public object BufferOverFlow<br />
{<br />
__get { return BufferOverFlow; }<br />
__set { BufferOverFlow = value; }<br />
}
|
|
|
|
|
Situation:
I'm working on an application (C# in .Net 2.0) where the user is able to enter some sensitive data (eg passes) in the options.
This sensitive data has to be stored in a secure (encrypted) manner - so that nobody outside the application can read the data - but of course the application itself should be able to read it on later occasions.
First I thought an encrypted xml would be fine, but then the key for encryption has to be shared - an idea I really don't like - even when the key is encrypted as well (then the key for the key must be shared).
Hash encryption is no option for me, because I don't like to bother the user with a password entry on startup, or something like that, when everything is alread entered in a previous session via the options.
Question:
How do applications like Outlook or instant messanger do store sensetive data (like mail server passes)- via an encrypted good hidden file? or is it a registry entries? or something else?
I'm open for everything, as long the sensitive data is stored in a safe manner; and if your ideas do circle around encrypted xml or hash it's not a problem for me - maybe I took the wrong approach concerning those two.
Thx in advance
|
|
|
|