|
|
You should do your drawing in the Paint event.
|
|
|
|
|
tkanks you friends
i think answers will help me.
|
|
|
|
|
How do I loop through the form elements in C#?
Regards,
ma se
(South Africa)
|
|
|
|
|
Just use :
<br />
foreach(Control control in this.Controls)<br />
{<br />
}<br />
<br />
|
|
|
|
|
In addition to stancrm answer, if you want to be able to iterate through all the child controls as well you can use a simple recursion:
private void IterateControls(Control c)
{
if (c.Controls.Count > 0)
{
foreach (Control child in c.Controls)
{
IterateControls(child);
}
}
}
.
.
.
IterateControls(this)
|
|
|
|
|
Thanks to both of you, but just another problem, how would I display the contents of the textbox? I have the ID which I did like control.ID, but now I need the value of the box. I went through the list of options, but couldn't find something like value or so.
Please help.
|
|
|
|
|
|
|
All that I need to do is to loop through the form, check if the control is a textbox, if so, print the ID of the textbox, together with the value typed in the box.
Please help.
|
|
|
|
|
You can check when you are iterating through all the contols to see if it's a textbox like this (if c is your control):
if (c is TextBox)
{
TextBox tb = (TextBox)c;
}
Now that you have casted c to a textbox you should be able to access all it's properties.
|
|
|
|
|
or as an alternative
TextBox tb = c as TextBox
if(tb != null)
{
MessageBox.Show(tb.text);
}
Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
|
|
|
|
|
Somewhere there is something wrong with my code.
When I go a create my textbox dynamically I did it like this:
foreach (Hub h in lstHubs)
{
strHubs = strHubs + "<tr>" +
"<td width=\"15%\"><h5>" + h.HubName + "</h5></td>" +
"<td width=\"85%\">" + "<input type=\"text\" id=\"txtHub" + h.HubID + "\" size=\"7\" MaxLength=\"6\" class=\"InputText\" runat=\"server\" />%<br />" + "</td>" +
"</tr>";
}
When I do that loop of yours it does not bring back anything. So did I declare my textbox incorrectly?
Please help.
|
|
|
|
|
foreach(Control control in Controls)
{
TextBox textBox = control as TextBox;
if(textBox != null)
{
MessageBox.Show(textBox.Name + ":" + textBox.Text);
}
}
|
|
|
|
|
Thanks!!
What I am trying to is to display each hub, with a textbox next to it. There can be many many or few hubs for each hub group. I do it like this:
List<Hub> lstHubs = Hub.GetHubsByHubGroupID(Int32.Parse(cboHubGroup.SelectedValue));
foreach (Hub h in lstHubs)
{
strHubs = strHubs + "<tr>" +
"<td width=\"15%\"><h5>" + h.HubName + "</h5></td>" +
"<td width=\"85%\">" + "<input type=\"text\" id=\"txtHub" + h.HubID + "\" size=\"7\" MaxLength=\"6\" class=\"InputText\" runat=\"server\" />%<br />" + "</td>" +
"</tr>";
}
The way that I'm doing it seems like it's not adding it as a asp:Textbox control. I do not' know how to add it other wise to the table.
Please can toy help.
`
|
|
|
|
|
Thanks, this worked just fine.
Sorry for only getting back now.
|
|
|
|
|
Is there a class that provides Licensing mechanism for C# apps? Like a user must provide a product KEY (Registration Key) during installation?
If not then is there a tutorial or an article that I can look at? Thanks.
|
|
|
|
|
hi all,
in my form i display a print dialog after a messageboxbuttons.okcancel.
how will i decide if the user press 'ok' or 'cancel' on messagebox ???
is there a code to distinguish them ?
|
|
|
|
|
As you can see from the documentation, the MessageBox.Show()[^] method returns a DialogResult[^] which will tell you what button was pressed.
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
Yes...
You can get the return value from Show() method.
for example :
DialogResult dialogResult = MessageBox.Show("My Text", "My Title", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
if(dialogResult == DialogResult.OK)
{
}
else if(dialogResult == DialogResult.Cancel)
{
}
|
|
|
|
|
Hi,
this is simple. read this example from msdn
Private Sub ValidateUserEntry2()<br />
<br />
<br />
' Checks the value of the text.<br />
<br />
If ServerName.Text.Length = 0 Then<br />
<br />
' Initializes variables to pass to the MessageBox.Show method.<br />
<br />
Dim Message As String = "You did not enter a server name. Cancel this operation?"<br />
Dim Caption As String = "No Server Name Specified"<br />
Dim Buttons As Integer = MessageBoxButtons.YesNo<br />
<br />
Dim Result As DialogResult<br />
<br />
'Displays a MessageBox using the Question icon and specifying the No button as the default.<br />
<br />
Result = MessageBox.Show(Me, Message, Caption, MessageBoxButtons.YesNo, _<br />
MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign)<br />
<br />
<br />
' Gets the result of the MessageBox display.<br />
<br />
If Result = DialogResult.Yes Then<br />
<br />
' Closes the parent form.<br />
<br />
Me.Close()<br />
<br />
End If<br />
<br />
End If<br />
<br />
End Sub
Anant Y. Kulkarni
|
|
|
|
|
I need the control to mimic the functionality provided by OUTLOOK. i.e: the email can be grouped by DATE, FROM, TO etc. and each group can be collapsed and expanded to reveal more information.
So for example in our application...I want to see a list of clients grouped by CASE. every CASE group can be expanded to reveal the clients associated with that case
e.g:
===============================================
SURNAME ^ | NAME ^ | DATE ADDED
===============================================
- CASE A
Putter David 01 June 2006
Smith Kelly 24 May 2006
+ CASE B
+ CASE C
|
|
|
|
|
|
well listview 2.0 supports grouping but not expaned and collapse mode like you want. However, you use an off the shelf component called SandGrid it is produced by a company in the UK called DivElements. In my opinion this is a damn good component to use plus its very cheap. try http://www.divelements.co.uk/net/controls/sandgrid/
|
|
|
|
|
Thanks. How does one programmatically highlight or de-highlight a listview items which is sitting inside a listview control? i.e. what events get called
|
|
|
|