|
BillWoodruff wrote: The simple way to achieve a combination of Button(s) and TextBox, in one nice package, is to create a UserControl, Or just put them both in a Panel ?
/ravi
|
|
|
|
|
Good point, Ravi. I tend to make UserControls, perhaps because it's become "natural" for me to do so, and, if I create something with multiple controls wired together, interacting, etc., that's often something that I will want to re-use in the future, in other applications, which is so easy if it's a UserControl.
yours, Bill
~
“This isn't right; this isn't even wrong." Wolfgang Pauli, commenting on a physics paper submitted for a journal
|
|
|
|
|
Agree 100% for reuse.
/ravi
|
|
|
|
|
I started to answer that one, stating it could not be done, then decided that someone may actually be able to do it. I'm glad to have that clarified. The usercontrol seemed a natural solution but not what the OP was asking for.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I'm trying to add folder images to my treeview component. I have looked at some examples but cannot quite understand the process.
I think I have to start with setting my images resources in an ImageList object right? I'm not sure how to do that.
Then as I build my treeview, how do I detect a folder from a file and if a folder, set an image to it to display a folder?
Thanks for any help.
|
|
|
|
|
I suggest you move this question to the QA forum, and tag it so we know exactly what you are working with: C#, WinForm, or whatever. Also, please indicate if you are using the standard Microsoft TreeView, that's part of Visual Studio, or, if not, what control You are using.
There are many resources already here on CodeProject demonstrate enumerating a drive/directory structure recursively, and setting TreeNode images: did you search ?
yours, Bill
~
“This isn't right; this isn't even wrong." Wolfgang Pauli, commenting on a physics paper submitted for a journal
|
|
|
|
|
(1) I searched outside of this forum but I will search inside and see what I can find.
(2) I don't see a way to move a topic? I don't see a Move button or link. I'd be glad to move this to QA if I can see how to do that.
Thanks...
|
|
|
|
|
Hi,
The simplest way is to just copy your OP, paste it in a text-editor so you don't accidentally lose it, delete the question here, and then post a new question on QA, paste in the previous question, and then select the appropriate tags.
If you do search CP, I think you'll find existing articles, and answers to other questions, will give you what you need quickly. If you get "stuck," I, and I am sure others, will respond on QA.
yours, Bill
~
“This isn't right; this isn't even wrong." Wolfgang Pauli, commenting on a physics paper submitted for a journal
|
|
|
|
|
The Delete link is disabled so I can't delete it to move it.
I did a search and 'figured out' that I could populate the imagelist property in my treeview with my needed images. I have a brown folder for directories and a green folder for files but in my code below, the folders don't get the brown folder icon and the one file does not get the green folder!
I thought after I understand finally that the index into the images could be used to set the folder icon. Below in directory loop I'm setting 0 index which has the brown folder and the loop below that one is for files and I set index 1 which is the second green folder image.
foreach (var directory in directoryInfo.GetDirectories())
{
var childDirectoryNode = new TreeNode(directory.Name) { Tag = directory };
currentNode.Nodes.Add(childDirectoryNode);
currentNode.ImageIndex = 0;
stack.Push(childDirectoryNode);
}
foreach (var file in directoryInfo.GetFiles())
{
currentNode.Nodes.Add(new TreeNode(file.Name));
currentNode.ImageIndex = 1;
}
|
|
|
|
|
Re: can't delete message: I guess that once responses have been made to a post it can't be deleted on this type of forum. That's something I've never thought about before, and I apologize if I misled you.
Looking at your code, I can't quite follow what you're doing: your pushing Directories on a Stack, in the first loop, but in your second loop, traversing the files, I can't see where the Stack is being used. Neither loop shows where 'currentNode is being set. And, 'childDirectoryNode is, of course, contained in the scope of the loop that traverses the Directories.
My guess is: the two loops you show are separate pieces of code, and that they are connected in some way not shown, perhaps in a recursive outer method ?
Are you using WinForms, and the MS standard TreeView ?
Do keep in mind that for the WinForms TreeView you can set the default Node image at design-time by either the 'ImageIndex or 'ImageKey property of the TreeView (assuming you've set the 'ImageList property of the TreeView to a valid ImageList). Those two properties are "mutually exclusive:" you set one, and it "disables" the other.
I'd suggest you start by finding an example that uses just recursion, and doesn't use a Stack (although using a Stack to reduce the "overhead" of recursion is a very good thing).
good luck, Bill
~
“This isn't right; this isn't even wrong." Wolfgang Pauli, commenting on a physics paper submitted for a journal
|
|
|
|
|
See this[^] article.
/ravi
|
|
|
|
|
You should create an ImageList and then assign images from the list to the nodes like
node.ImageIndex = 0;
this will assign the image at index =0 to the node. Better assign the images to the nodes while creating that node; either that node is the folder node or a list node.
|
|
|
|
|
I created a chart showing a data serie including X value year and Y value MarketValue of my cars' collection. Suppose I have a dictionary containing car model and car year. Using the mouse on the chart I need to visualize X and Y value and the name of car model. To show X and Y I use the following code:
chart1.Series["CAR"].ToolTip = "Year: #VALX MarketValue: #VALY"
If I want to show also the model name, any idea?
Dictionary<int,string> D = new Dictionary<int,string>();
D.Add(1982,"Cinquecento");
D.Add(2000,"Espace");
chart1.Series["CAR"].ToolTip = "Year: #VALX MarketValue: #VALY Model: "
Any idea?
Thanks for your time
|
|
|
|
|
Moved to asp.net forums.
=)
modified 21-Aug-13 7:04am.
|
|
|
|
|
Forbiddenx wrote: Need suggestions to design issue in asp.net. I suggest you try the ASP.NET Forum[^].
Use the best guess
|
|
|
|
|
Hi everyone!
My C# Project is using MySQL stored procedure to execute sql query.
My question is How will I retrieve all rows in select * statement and put in a class? For example.
[Row column]..........[Class 'User' member]
user_name -----> userName
user_id ---------> userID
I do not have idea at all since I am new to this C# and MySQL tandem.
Thank you in advance.
|
|
|
|
|
|
MySqlCommand cmd = new MySqlCommand("ProcName", new MySqlConnection("ConnectoinStringHere")); // ProcName should be the name of the procedure which you want to call
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection.Open();
MySqlDataReader dataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
// Now you have all the data in the dataReader. So, you can loop through the datareader like
while (dataReader.Read())
{
string name = dataReader["Name"].ToString(); // this will store the Name (which is a column_name in the database) to a local variable
}
dr.Close();
But it is suggested to not get the full data of a table into the memory unless you really require it.
|
|
|
|
|
HI!
I tried to code a simple tool, that uploads my XML Files to www.meinpaket.de. But each time I try it, I get a 403 Exception.
Can someone explain me, what is wrong here? WebResponse oWebResponse = oWebRequest.GetResponse() is raising the Exception.
Thanks for Help
public class MeinPaketRequest
{
public string TestURL { get; set; }
public string URL { get; set; }
public string Username { get; set; }
public string Password { get; set; }
public bool Test { get; set; }
CookieContainer _cookies = new CookieContainer();
public MeinPaketRequest()
{
this.TestURL = "https://mp-api.mepa-home.de/dealerapi/xml";
this.URL = "https://www.meinpaket.de/dealerapi/xml";
this.Test = true;
this.Username = "Username";
this.Password = "Password";
}
public string Request(string Filename)
{
if (string.IsNullOrWhiteSpace(Filename))
{
Filename = "C:\\Users\\TWGT-KASSE-2\\Desktop\\MeinPaket\\Beispieldateien_042013\\mp_example_30_01_download_orders.xml";
}
XmlDocument xDocument = new XmlDocument();
xDocument.Load(Filename);
foreach (XmlNode oNode in xDocument.ChildNodes)
{
if (oNode.Name == "dataRequest")
{
foreach (XmlNode oNodeRequest in oNode.ChildNodes)
{
if (oNodeRequest.Name == "header")
{
foreach (XmlNode oNodeHeader in oNodeRequest.ChildNodes)
{
if (oNodeHeader.Name == "password")
oNodeHeader.InnerText = this.Password;
if (oNodeHeader.Name == "login")
oNodeHeader.InnerText = this.Username;
}
}
}
}
}
HttpWebRequest oWebRequest = null;
if (this.Test)
{
oWebRequest = (HttpWebRequest)WebRequest.Create(this.TestURL);
}
else
{
oWebRequest = (HttpWebRequest)WebRequest.Create(this.URL);
}
oWebRequest.CookieContainer = _cookies;
oWebRequest.Accept = "*/*";
oWebRequest.KeepAlive = true;
oWebRequest.UseDefaultCredentials = true;
oWebRequest.UserAgent = "Mozilla/5.0";
oWebRequest.PreAuthenticate = true;
oWebRequest.Credentials = new NetworkCredential(this.Username, this.Password);
oWebRequest.ContentType = "text/xml";
oWebRequest.Method = "POST";
byte[] bytes = Encoding.UTF8.GetBytes(xDocument.InnerXml.ToString());
oWebRequest.ContentLength = bytes.Length;
using (Stream oStream = oWebRequest.GetRequestStream())
{
oStream.Write(bytes, 0, bytes.Length);
}
using (WebResponse oWebResponse = oWebRequest.GetResponse())
{
if (oWebResponse == null)
return null;
using (StreamReader oStreamReader = new StreamReader(oWebResponse.GetResponseStream()))
{
return oStreamReader.ReadToEnd().Trim();
}
}
}
}
|
|
|
|
|
It might be worth finding a forum that specialises in meinpacket's dealer API, especially given it is in German.
My best guesses:
The username and password combination are wrong. Check these first as it is the simplest fix.
You pass the username and password in the XML body itself. This could be correct, but if I was writing the API I'd want security at the HTTP level so people couldn't just send any old guff to my service to see if they can hack it. I'd expect the HttpWebRequest.Credentials[^] property to be populated. If needed the credentials could be different to the XML ones, this is something you'd need to check with your provider. https://mp-api.mepa-home.de/dealerapi/[^] 403's suggesting it needs the extra creds, https://mp-api.mepa-home.de/dealerapi/xml[^] doesn't so it's anybody's guess.
|
|
|
|
|
It is the same, when I do not change anything inside the XMLDocument. And I populate the credentials in this line
oWebRequest.Credentials = new NetworkCredential(this.Username, this.Password);
The Problem is, I can't upload any request at all. So I think, this is an error I am doing. But I do not know what I am doing wrong here.
|
|
|
|
|
You may not even need that line. You really need to talk to the MeinPacket people, only they know what their security is.
Security (especially with a 3rd party) is normally a PITA, especially if they provide inadequate support and info.
|
|
|
|
|
Do you also have an example app or something that does work, so you can compare the network traffic?
|
|
|
|
|
How To implement the N number of thread in c#
|
|
|
|
|
There are many ways. Without knowing what you are really after here, I'll go with the obvious answer of a loop and the Thread[^] class.
|
|
|
|