|
Not sure what you want: is it "how do I use the open and save dialogs in c#"? If so, then look at OpenFileDialog[^] and SaveFileDialog[^]
If not, then we need more information.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Hi
i want to display hierarchical data in treeView, for example i have a recursive query which get employees and his/her manager in northwind database like this :
WITH cte1 (LastName, EmployeeID, Manager, ManagerID, Level)
AS
(
SELECT e1.lastName, e1.employeeID, e2.LastName, e1.ReportsTo, 0
FROM Employees e1 LEFT JOIN employees e2 on e1.ReportsTo = e2.EmployeeID
WHERE e1.ReportsTo IS NULL
UNION ALL
SELECT e1.lastName, e1.employeeID, c.LastName, e1.ReportsTo, Level + 1
FROM Employees e1 JOIN cte1 c ON e1.ReportsTo = c.EmployeeID
)
SELECT * FROM cte1
now, i want to display this result set to treeview in hierarchical mode, but i don't know how to do this. can anybody provide source code ?
thanks
|
|
|
|
|
Consider the following...
struct Node
{
unsafe { public Node* parentNode; }
public int someData;
}
class SomeClass
{
Node[] nodeArray = new Node[2];
Node[] otherNodeArray = new Node[1];
void LinkEmUp()
{
unsafe
{
nodeArray[0].parentNode = &nodeArray[1];
otherNodeArray[0].parentNode = &nodeArray[0];
}
}
}
And to add, lets say that an instance of SomeClass has a Node array where an element's parentNode points to a Node in another SomeClass instance's array.
Would the pointer chain will be intact after a garbage collection or after the CLR does something to change the reference types memory locations? Is it even possible to make linked lists and reference/pointer chains with .NET value types?
EDIT:
I figured it out. In the example above, the consumer of SomeClass would have to use the fixed statement to fix SomeClass and the two Node arrays. The Node arrays would also have to be made public so that the consumer can directly access them.
class SomeClass
{
public Node[] nodeArray = new Node[2];
public Node[] otherNodeArray = new Node[1];
public void LinkEmUp()
{
unsafe
{
nodeArray[0].parentNode = &nodeArray[1];
otherNodeArray[0].parentNode = &nodeArray[0];
}
}
}
Consumer
unsafe static void Main()
{
SomeClass c = new SomeClass();
fixed(Node* _temp = &c.nodeArray[0], __temp = &c.otherNodeAray[0])
{
c.LinkEmUp();
...
}
}
As far as my question about linked lists with C style structs, its possible if I use native API or Marshaling to allocate memory.
Another way is stack based linked lists built through recursion which I don't understand how it could be of any use that way.
modified on Saturday, October 24, 2009 11:28 PM
|
|
|
|
|
CaptainSeeSharp wrote: Would the pointer chain will be intact after a garbage collection or after the CLR does something to change the reference types memory locations? Is it even possible to make linked lists and reference/pointer chains with .NET value types?
The problem you have is that it points to a memory address that has been GCed. I'm unsure how the pointer chain would stay intact as .NET moves things around in memory, but I am certain that, just like C++, once you clean up a node, your chain is broken.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
What I really want to know is if it is possible to create a linked list in .NET using a valuetype Node that uses a pointer to point to other valuetype Nodes. If it is possible, I would like to see a small example.
|
|
|
|
|
I would think that having a class and passing the instances ( which are by ref ) is all you need to create a linked list. So long as none of the nodes are deleted along the way.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Who could have voted you down on this? Seems to be more pettiness floating around here of late. Anyway, 5'd to counter it.
only two letters away from being an asset
|
|
|
|
|
CSS downvoted me for answering by explaining a better design, because he was asking a .NET question in general, not actually trying to write a linked list. Oh, and because I was the one helping him, I bet that burned him up.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Wow - I didn't even realise I was replying to you ( not that it would have changed my answer ). I get a one vote for helping you ? How does that work ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I want to know if I can link Nodes of
struct Node
{
unsafe { public Node* parentNode; }
}
Would the chain hold together? I want to articulate what goes on behind the scenes in the CLR.
class SomeClass
{
Node[] nodeArray = new Node[2];
Node[] otherNodeArray = new Node[1];
void LinkEmUp()
{
unsafe
{
nodeArray[0].parentNode = &nodeArray[1];
otherNodeArray[0].parentNode = &nodeArray[0];
}
}
}
I don't want to here "just change Node to class and don't use pointers" because that is not what I am asking.
modified on Saturday, October 24, 2009 10:08 PM
|
|
|
|
|
CaptainSeeSharp wrote: I don't want to here "just change Node to class and don't use pointers" because that is not what I am asking.
I see you still can't spell.
You need to make clear if what you're saying is 'I know my design is stupid, but I'm trying to illustrate a point'. If you have a pointer to an object, and that object is GCed, then your pointer is as valid as a pointer to a deleted object in C++.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
|
I need to be able to place the captcha image into a picturebox on my form, the reason being that I need to zoom the captcha image for the visualy impaired users.
It appears to be such a simple task, just take the image from the web page and put it into a picturebox but it is turning out to be not so simple.
i have WebBrowser control in form and for registration in one of site, i need captcha image in picture box. problem is that captcha image is generated by JavaScript, when java script runs then it gives url of captcha image. but every time when java script runs, captcha image goes change. i just want that captcha image which is on WebBrowser control current page.
Any help would be greatly appreciated.
yogesh
|
|
|
|
|
No you cant create pictures using Javascript. You need to generate the picture in the serverside using Bitmap object.
This might help you
CAPTCHA Image[^]
|
|
|
|
|
i dont want to create captcha using javascript. i just told that captcha link comes when javascript runs.
yogesh
modified on Saturday, October 24, 2009 1:49 PM
|
|
|
|
|
you need to change the size of the image ?
why dont you use javascript to do this??
set <img style="width:100px; height:100px" /> using javascript when user wants to zoom the image.
|
|
|
|
|
i think, you have not read my message carefully. ok i am explaining again,
if you are going to create account in facebook.com, captcha will come there. if you see the page source then you can not get any specifice captcha url, you only get one link, and this links calls java script. whenever java script runs captcha url comes to webpage.
yogesh
|
|
|
|
|
Hey ultimately it goes to a handler right. So calling the handler again will create a new image.
If javascript calles the handler then it should create an img tag. In your case, if you have an HTTPhandler you can easily write the captcha image in the output stream and through javascript create an img tag and place the image.
Now place a button to enlarge the existing image using
var img = document.getElementById('yourimgkey');
img.style.width = '100px';
img.style.height = '100px';
That will do the trick I think. why do you require to request to the server again. I know its an issue when you are hitting the server side again, the captcha image will change.
If still have problems, Please drop some code that you have done for your website so that I could get more about the actual problem you are facing.
|
|
|
|
|
here is my code.
public void FacebookRegistration()
{
HTMLDoc = (mshtml.HTMLDocument)WBrowser.Document.DomDocument;
iHTMLCol = HTMLDoc.getElementsByTagName("input");
foreach (IHTMLElement iHTMLEle in iHTMLCol)
{
if (iHTMLEle.getAttribute("name", 0) != null)
{
strAttriName = iHTMLEle.getAttribute("name", 0).ToString();
if (strAttriName == "firstname")
{
iHTMLEle.setAttribute("value", FirstName, 0);
continue;
}
if (strAttriName == "lastname")
{
iHTMLEle.setAttribute("value", LastName, 0);
continue;
}
if (strAttriName == "reg_email__")
{
iHTMLEle.setAttribute("value", EmailID, 0);
continue;
}
if (strAttriName == "reg_passwd__")
{
string s = GetRandomString();
Random ran = new Random();
iHTMLEle.setAttribute("value", s+ran.Next(1111,9999), 0);
break;
}
}
}
iHTMLCol = HTMLDoc.getElementsByTagName("option");
foreach (IHTMLElement iHTMLEle in iHTMLCol)
{
try
{
if (iHTMLEle.innerText.Contains("Male"))
{
iHTMLEle.setAttribute("selected", "selected",0);
} if (iHTMLEle.innerText.Contains("Jun"))
{
iHTMLEle.setAttribute("selected", "selected", 0);
}
Random ran = new Random();
if (iHTMLEle.innerText.Contains("4"))
{
iHTMLEle.setAttribute("selected", "selected", 0);
}
Random ran1 = new Random();
if (iHTMLEle.innerText.Contains(ran1.Next(1920,1985).ToString()))
{
iHTMLEle.setAttribute("selected", "selected", 0);
}
}
catch { }
}
iHTMLCol = HTMLDoc.getElementsByTagName("input");
int i = 0;
foreach (IHTMLElement iHTMLEle in iHTMLCol)
{
string s = iHTMLEle.className;
if (iHTMLEle.className == "UIButton_Text" && iHTMLEle.getAttribute("value", 0).ToString() == "Sign Up")
{
if (i != 0)
{
iHTMLEle.click();
break;
}
i++;
}
}
private void WBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
if (CurrentSocial == "facebook")
{
FacebookRegistration();
}
}
in the registration page of facebook.com, there is captcha and if you go to page source then you will see only this:
yogesh
|
|
|
|
|
Basically, the idea is that they are trying to stop exactly what you're trying to do, and seem to be doing so successfully.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
So you are making a windows application which will load the Facebook application to its web browser control. First of all, you need to remember, if you are going to call the server again, it will load the CAPTCHA again. This is the basic feature of CAPTCHA. Rather if your motive is to zoom the image, you need to find the img control which loads the captcha and then apply CSS width and height.
Just try to find the actual img control that loads the captcha. I am sure that must be one.
|
|
|
|
|
yogesh_softworld123 wrote: I need to zoom the captcha image for the visualy impaired users.
Why not go for the audio facility? Wouldn't that be better?
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
I have a datagridview with for columns. the datagridview is dinamically added. the 4th column is needed for an cellClick event so I have to have it. But I do not want to display it so I set the Visible property for that column to false. and it does not show. Cool right? Except in the process of making this column not visible the header text for all the columns dis appear;
I could set the with of the DataGrid to chop off the last column so its still there but no one can see it. and this is probably what im going to do but was wondering if anyone had this problem or a resolution to this.
Mike
|
|
|
|
|
ok Never mind. The headerText was not showing because I did not set the foreColor in the column that was not to be visible.
|
|
|
|
|
Then, please mark your question as [solved]. if it is!
♫ 99 little bugs in the code,
99 bugs in the code
We fix a bug, compile it again
101 little bugs in the code ♫
|
|
|
|