Originally Posted by daccit
: public void CheckedBox1l_CheckedChanged(object sender, EventArgs e)
CheckBox Mychk = (CheckBox)sender;
Panel MyPanel = (Panel)FormView1.FindControl("Panel2");
MyPanel.Visible = Mychk.Checked;
It's easier to convert code in a language you're not comfortable with into your own language because that way the final product at least makes sense because you know the syntax. Therefore, I'd recommend that you translate it into VB
yourself, since daccit and I are primarily C# guys. You don't want to see how many compilers our VB
suggestions would throw. :) You are simply creating an event handler for a particular checkbox, CheckedBox1, when it's state is changed (it's checked or unchecked). Here's what's going on in this example, this is the code you're trying to recreate in VB
First you create a new checkbox control in code, Mychk, and load the checkbox which has changed (the sender) into it. This is why you are casting the sender, so that it is the correct type when you store it in Mychk. You then repeat this process with the panel. You create a new panel in code, MyPanel. Using the FindControl() method you retrieve the panel with id="Panel2" that's inside FormView1, not that again you have to cast it to the correct type (Panel) in order to assign it to MyPanel (just like you had to for Mychk).
The third step is actually two steps combined. You are setting the visible property of MyPanel to true (which makes it visible) or false. However, you don't see any booleans, because the code directly assigns the Checked value (which is either true or false) from the Mychk checkbox. So if someone checks the checkbox, it's state changes and this function fires. The value of the checkbox is now checked and so this statement is true; line three assigns this "true" value to the visible property of the panel and the panel therefore appears. Now if someone unchecks the box, it's status changes and this function fires again. Now it's not checked so the Checked value is "false" and when that's assigned to MyPanel.Visible, the panel disappears. I hope that's clear?