|
|
Dear Experts,
I have a problem during change image for child level in each node, I have assigned an image to treeview, and I have assigned other image to selected Node, I need to assign an image for the some childs in each node.
For example:
Root
|_Node1
|_Child1 (Need to assign image)
|_Child2 (Need to assign image)
|_Child3 (Need to assign image)
I have populate the treeview from Database recursively.
Thanks,
Ahmad
|
|
|
|
|
Is it the case that you don't know what nodes are in the TreeView until it is populated ... so you have to navigate the populated TreeView and assign images to nodes based on their depth (TreeNode.Level) ?
Your question implies something about selecting nodes, but I am not clear what that is.
If you can be more specific, I think I have some code that will be helpful (I've spent years working with the TreeView).
In any case, I am pretty sure you will need to use an ImageList to hold all possible images for the nodes: do you have that already implemented ?
« I had therefore to remove knowledge, in order to make room for belief » Immanuel Kant
|
|
|
|
|
Dear ,
Thank for your response,
Actually, what I'm going to do is:
I have a tree with folder, and these Nodes, some of these nodes is played as a child use to open Forms,
for Example,
General Ledger
|_GL Transactions
|_Enter GL Transaction
Enter GL Transaction: is a child that I need to change the image for it, it is not a Folder, it is a child that will be used to open a Form.
For previous node, I select a Folder image for them.
I hope of you receive my point.
Regards,
Ahmad
|
|
|
|
|
Sorry, Ahmed, I don't yet understand your question.
The Microsoft supplied TreeView Control has two ImageList Properties: ImageList, and StateImageList. ImageList is used to specify the image shown when the TreeNode is selected, or not selected. StateImageList is used to control the image shown for the Node when shown with a CheckBox, and the CheckBox checked or unchecked.
Each TreeNode in the TreeView can have its current image changed at any time by setting either the Index or Key of the ImageList assigned to the TreeView.
treeView1.Nodes[3].ImageIndex = 2; // set the Image for the Node when it's not selected
treeView1.Nodes[3].SelectedImageIndex = 3;; // set the Image for the Node when it's selected
See the Microsoft documentation for ImageList: [^]
« I had therefore to remove knowledge, in order to make room for belief » Immanuel Kant
|
|
|
|
|
Thank you sir,
Your suggestions about TreeNode.Level and treeView1.Nodes[3].ImageIndex = 2 , will help me.
|
|
|
|
|
You can, of course, post other questions here, or in the QA forums.
Keep in mind that for any TreeNode you have several possible 'dynamic visual state' factors that may determine your choice of images to be used in displaying the node:
1. has child nodes, or has no child nodes
2. if has child nodes: is expanded, or collapsed
3. is selected, or is not selected: unfortunately unless you owner-draw the TreeView you have no control over the selection highlight color, and every scheme I have seen to work-around this (using the TreeView as is: i.e., not owner-drawn) has been not useful (impaired performance, etc.).
4. the current level: this could be a dynamic factor if you are implementing drag-drop in the TreeView
To assist you in determining the node's current state at run-time there are four boolean properties which are read-only:
IsEditing
IsExpanded
IsSelected
IsVisible
cheers, Bill
« I had therefore to remove knowledge, in order to make room for belief » Immanuel Kant
|
|
|
|
|
..'tis was downvoted, but I cannot think of any valid reason why. So, I upvoted it.
If anyone thinks this is NOT a good way to answer, please do explain it to me, using small short* sentences and simple words.
*edit
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Thanks, Eddy, I appreciate your concern for "technical justice" !
cheers, Bill
« I had therefore to remove knowledge, in order to make room for belief » Immanuel Kant
|
|
|
|
|
Hi,
I am using the following to loop through date range and import into a database from text files. I want to know how can I tell the code IF FILE DOES NOT EXITS THEN CONTINUE TO NEXT FILE?
for (DateTime date = last_date; date.Date <= DateTime.Today; date = date.AddDays(1))
{
string file_name = "H" + date.ToString("yyyy-MM-dd") + ".TXT";
MySqlBulkLoader bl = new MySqlBulkLoader(sql_connection);
bl.TableName = "processing_table";
bl.FieldTerminator = ",";
bl.LineTerminator = "\n";
bl.FileName = @"C:\Temp\Attendence\" + file_name;
bl.NumberOfLinesToSkip = 0;
int count = bl.Load();
string sql = "SELECT source, created_date, created_time, company, action, employee_number, employee_name, outlet, field_1, field_2, field_3, field_4 FROM processing_table";
MySqlCommand cmd = new MySqlCommand(sql, sql_connection);
MySqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
SplashScreenManager.Default.SetWaitFormDescription(rdr[1] + " - " + rdr[2]);
}
rdr.Close();
}
Technology News @ www.JassimRahma.com
|
|
|
|
|
I´m not sure where it´s failing, but try creating a FileInfo object (System.IO.FileInfo) that object has an exists method that will return true/false if a file exists.
|
|
|
|
|
|
|
Aight, I'd accept it if you posted it once, but it the URL is NOT a valid question to "all" answers.
You have been promoted to spammer.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
string file_name = "H" + date.ToString("yyyy-MM-dd") + ".TXT";
If (!File.Exists(file_name))
{
continue;
}
else
{
MySqlBulkLoader bl = new MySqlBulkLoader(sql_connection);
}
Something similar to this should be what you're looking for.
|
|
|
|
|
string filepath = @"C:\\"+"Search.xls";
string sheetName = "general_report";
var excelFile = new LinqToExcel.ExcelQueryFactory(filepath);
excelFile.DatabaseEngine = DatabaseEngine.Ace;
|
|
|
|
|
Please don't double-post, you can edit the first post if you need to.
|
|
|
|
|
What's your question?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Code is string filepath = @"C:\\"+"k.xls";
string sheetName = "general_report";
var excelFile = new LinqToExcel.ExcelQueryFactory(filepath);
excelFile.DatabaseEngine = DatabaseEngine.Ace;
|
|
|
|
|
Member 11053420 wrote: @"C:\\"
Use either @ (verbatim string) or escape the backslash, not both. And why concatenate?
string filepath = @"C:\k.xls";
ought to do it.
|
|
|
|
|
Only works if the entire process is 64-bit.
"Didn't work out", what does that mean? Did it throw an exception, did it explode?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hello. I have started a process using Process.Start . Now when I resize my panel, I also resize this control. But the problem is, it stops resizing after I drag its border just a little bit. It does, though, resize for that little bit drag of form border. So question is why can not I resize my external program along with panel, just like I resize my panel along with form? Thanks for any pointer.
UPDATE
I have a process that I have started using Process.Start() and placed it on the panel, on my form. Now in order to resize it, I put this code
private void Form1_SizeChanged(object sender, EventArgs e)
{
SetWindowPos(m_hHandle, 0, 0, 0, panel1.Width, panel1.Height, SWP_SHOWWINDOW);
}
I put a breakpoint on this function and noticed that as soon as I resize my form, this breakpoint gets hit. How do I resize this control on my form using Resize or SizeChanged events?
This world is going to explode due to international politics, SOON.
modified 19-Sep-14 3:52am.
|
|
|
|
|
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
Edit your question and provide better information.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
I have a process that I have started using Process.Start() and placed it on the panel, on my form. Now in order to resize it, I put this code
private void Form1_SizeChanged(object sender, EventArgs e)
{
SetWindowPos(m_hHandle, 0, 0, 0, panel1.Width, panel1.Height, SWP_SHOWWINDOW);
}
I put a breakpoint on this function and noticed that as soon as I resize my form, this breakpoint gets hit. How do I resize this control on my form using Resize or SizeChanged events?
This world is going to explode due to international politics, SOON.
|
|
|
|
|
I note you use the word 'Control to describe what you are working with, but using Process.Start runs an Application that then puts up a window(s).
1. what is the Application you start using Process.Start ?
2. what are you doing to make that Application's Window(s) a child Control of the Panel (added to the Panel's ControlCollection) ? or, is it (more likely), that the application window is not a child of the Panel ?
3. is it possible that whatever application you start's window has a fixed window size maximum ?
4. if you make the Panel size smaller: what happens to the hosted whatever ?
More specific details, please.
« I had therefore to remove knowledge, in order to make room for belief » Immanuel Kant
modified 19-Sep-14 4:56am.
|
|
|
|
|