|
To clarify, are you filling a single textbox with more than one value from your database? Or do you have completely empty textboxes and want to format the empty spaces out of the form?
|
|
|
|
|
just one value for each text field. I have the address one under the other and there are making my page look bad. I want to format the empty spaces out
Ferron
|
|
|
|
|
I'm no expert, so there's only one solution I could think of that would work:
if (textbox1.TextLength < 1)
{
textbox2.Location.Y -= [int HeightOfTextbox];
}
I think the location 0,0 is in the upperleft corner, so this should be the right equation, but don't quote me on it. I haven't actually tested this.
modified on Wednesday, February 11, 2009 4:45 PM
|
|
|
|
|
Just for some extra info, you can do this slightly better:
Use pre tags for instance.
And do it like this:
if(String.IsNullOrEmpty(textbox1.Text))
{
textbox.Visible = false;
}
|
|
|
|
|
visible doesn't remove the space there. jst don't show
Ferron
|
|
|
|
|
He was commenting on the formatting of my post, but you should note how he set up his if-statement.
|
|
|
|
|
I was trying to move some the labels with the location.Y method but it doesn't seem to be working. Any help on how get rid of the empty labels as well?
Ferron
|
|
|
|
|
Use the visible property shown in Deresen's post to hide labels you don't want shown.
The labels should be able to move the same as your textboxes.
if (String.IsNullOrEmpty(textbox.Text))
{
textbox.Location.Y -= textbox.Height;
label.Location.Y -= textbox.Height;
}
modified on Wednesday, February 11, 2009 6:01 PM
|
|
|
|
|
i know know how to hide them that's not the problem. The problem is
my form is like this:
--------info--------
[ ]
--------info--------
i want to remove the space created by the empty textbox/label or move it to another location where it doesn't take up space
Ferron
|
|
|
|
|
I understand. In theory I figured it would work to move the controls below the empty textboxes up to fill in the gap, however I can't seem to get it working. Hopefully someone a little more knowledgeable will swing by. In the meantime I'll try and figure it out myself and let you know if I come up with anything. I'm still a newbie, myself.
|
|
|
|
|
So you have this:
line 1
line 2
line 4
and you want to have it like this:
line 1
line 2
line 4
If I understand you well, you would like to have it is above.
If that is what you want, you have to program dynamically.
This is what I always do when it is about dynamic programming:
String[] myLines = {"line 1", "line 2", "", "line4"};
int lineheight = 23;
int top = 10;
int left = 20;
int width = 200;
Label l;
foreach(String myLine in lines)
{
if(!String.IsNullOrEmpty(myLine))
{
l = new Label();
l.Location = new Point(left, top);
l.Width = width;
l.Text = myLine;
this.Controls.Add(l);
top += lineheight;
}
}
|
|
|
|
|
Error 646 'System.Web.UI.WebControls.Label' does not contain a definition for 'Location' and no extension method 'Location' accepting a first argument of type 'System.Web.UI.WebControls.Label' could be found (are you missing a using directive or an assembly reference?)
That's the error is got when i tried using the Location.Y method
Ferron
|
|
|
|
|
Ah, I think I've figured it out.
Read this:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.location.aspx[^]
And you should understand why you have to do it like this:
if (String.IsNullOrEmpty(textbox.Text))
{
textbox.Location = new Point(textbox.Location.X,(textbox.Location.Y - textbox.Height));
label.Location = new Point(textbox.Location.X, (textbox.Location.Y - textbox.Height));
}
Again, I think it should work but I could be wrong. Hahaha...
|
|
|
|
|
textBox.Location.X is the same as textBox.Left
and
textBox.Location.Y is the same as textBox.Top
It's not that your code is bad, because it's the same. But it's a little shorter.
|
|
|
|
|
Ah, I see! Thanks Deresen, that will be handy to know!
|
|
|
|
|
Hey there,
Lodeclaw was right, why don't you handle it while filling it "your database", anyways, you can use the DECODE function from the database
DECODE(ColumnName,' ','');
Or in the forms
YourTextBox.Text = YourTextBox.Text.Replace(" ","");
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
|
|
|
|
|
thanks guys for the help. It was gladly appreciated
Ferron
|
|
|
|
|
Hello guys I have a data transfer class in which among all the code in it i have created 2 events. in the envent handler of the event DownloadBegin im running a new form. The code below demonstrates what im doing.
//Events
public event delegateNull DownloadBegin;
public event delegateNull DownloadFinished;
//Event Handler
private void btnListenforConnections_Click(object sender, EventArgs e)
{
//Start listing for incoming connection from client applications
transfer.StratListiningForIncomingConnections();
lblincomingconnection.Text = "Listening for incomming connections";
transfer.DownloadBegin += new Transfer.delegateNull(transfer_DownloadBegin);
}
void transfer_DownloadBegin()
{
frmDownloadDataProgressBar progressbar = new frmDownloadDataProgressBar();
progressbar.Show();
}
The problem is when the form is being displayed it gets stuck for some reason.
|
|
|
|
|
Ever heard of Break Points and Debugging?? You might wanna try that first.
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
|
|
|
|
|
Hi,
I am new to programming...
I am using Delegates in my program..
public delegate MyTable MyDelegate2(DataTable ddt, double dcost);
public class MyTable
{
public DataTable ddt;
public double dcost;
public static MyTable tablevalue(DataTable ddt, double dcost)
{
MyTable mytable = new MyTable();
mytable.ddt = ddt;
mytable.dcost = dcost;
return mytable;
}
}
How can i retrieve these return values in an event(button_click). These values are set by Other method.
Thanks
|
|
|
|
|
One of the most easiest way you can design it is, using a Static class as you have already done. Have static properties to set the static member variables. Anyone can then access the static properties and can set/get them.
public static class MyTable
{
public static DataTable Table { get; set; }
public static double Cost { get; set; }
}
|
|
|
|
|
Hi guys...I saw something in a code block that one of my colleagues wrote and I can't figure out exactly what it's doing. Google provided no help and the MSDN provided no help. The code in question looks something like this:
addUserRequest inValue = new addUserRequest();
inValue.persistUserRequest = parameterUserRequest;
addUserResponse retVal = ((UserManagement)(this)).addUser(inValue);
return retVal.@return;
What the F does '@return' do? Is that a shorthand call for something else?
"I need build Skynet. Plz send code"
|
|
|
|
|
@ is a valid, albeit odd, start character for member names. Right click and goto definition.
Need custom software developed? I do C# development and consulting all over the United States.
If you don't ask questions the answers won't stand in your way.
Doing a job is like selecting a mule, you can't choose just the front half xor the back half so when you ask me to do a job don't expect me to do it half-assed.
|
|
|
|
|
oh yeah!! ...now that you mention it, I do remember that from my "450" class back in college....could be wrong, but isn't that the "standard nomenclature" to use if you are wanting to name a member as a reserved keyword? [Even though you probably shouldn't be WANTING to use reserved keywords as member names]
"I need build Skynet. Plz send code"
|
|
|
|
|
"Standard"?? That depends on who you ask, because there's no real standard for this. But, in VB.NET, if you wanted to use a reserved word as an identifier, you'd put square brackets around it, like this:
Dim [Assembly] As Assembly
This is known as an "escaped identifier".
AFAIK, C# doesn't have an equivilent.
|
|
|
|