Rowspan不使用顶行(Rowspan not using top row)
我不明白为什么我的列不会跨越我创建的顶行和底行。 它应该看起来像“今天”列在顶部和底部比其他列更高。
这是很多代码,我不确定在不变形或添加新变量(它需要流体高度)的情况下应该切割什么。 JSFiddle: http : //jsfiddle.net/DaAwesomeP/aU9Le/
基本HTML布局:
<table id="weatherForecast"> <tr class="weatherForecast-row-outer"> <td></td> </tr> <tr id="weatherForecast-row"> <td id="weatherForecast-DATE" class="weatherForecast-day weatherForecast-day-today" rowspan="3"> <!-- Cell Content for "Today" Here --> <td id="weatherForecast-DATE" class="weatherForecast-day "> <!-- Cell Content Here --> </td> </tr> <tr class="weatherForecast-row-outer"> <td></td> </tr> </table>
这是一张显示我想要的图片:
I don't understand why my column won't span to the top and bottom rows I created. It is supposed to look like the "Today" column is taller on the top and bottom then the other columns.
It's a lot of code, and I wasn't sure what I should cut without deforming it all or adding a new variable (it needs a fluid height). JSFiddle: http://jsfiddle.net/DaAwesomeP/aU9Le/
Basic HTML Layout:
<table id="weatherForecast"> <tr class="weatherForecast-row-outer"> <td></td> </tr> <tr id="weatherForecast-row"> <td id="weatherForecast-DATE" class="weatherForecast-day weatherForecast-day-today" rowspan="3"> <!-- Cell Content for "Today" Here --> <td id="weatherForecast-DATE" class="weatherForecast-day "> <!-- Cell Content Here --> </td> </tr> <tr class="weatherForecast-row-outer"> <td></td> </tr> </table>
Here is an image that shows what I want:
原文:https://stackoverflow.com/questions/19736096
最满意答案
我已经测试了你的代码,实际上它们确实重叠了。 (每次迭代时,背景颜色中的红色增加y_value / 2)。
将PictureBox的高度设置为(fe)20,你会发现它们显示得很好:
Label[] l = new Label[15]; PictureBox[] pic1 = new PictureBox[15]; int y_value = 47; for (int i = 0; i < 6; ++i) { l[i] = new Label { Text = "Test Text", Font = new System.Drawing.Font("Calibri", 8, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte) (128))), ForeColor = System.Drawing.Color.White, BackColor = System.Drawing.Color.FromArgb(1, 0, 64), Size = new System.Drawing.Size(145, 20), Location = new Point(30, y_value), Anchor = AnchorStyles.Left, Visible = true }; pic1[i] = new PictureBox { Size = new System.Drawing.Size(400, 20), Location = new Point(2, y_value - 10), Anchor = AnchorStyles.Left, Visible = true, BackColor = Color.FromArgb(y_value/2, 0, 0) }; y_value += 37; } this.Controls.AddRange(l); this.Controls.AddRange(pic1);
I've tested your code and in fact they do overlap. (increased red in backgroundcolor by y_value / 2 every iteration).
set height of your PictureBox to (f.e.) 20 and you will see that they show up just fine:
Label[] l = new Label[15]; PictureBox[] pic1 = new PictureBox[15]; int y_value = 47; for (int i = 0; i < 6; ++i) { l[i] = new Label { Text = "Test Text", Font = new System.Drawing.Font("Calibri", 8, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte) (128))), ForeColor = System.Drawing.Color.White, BackColor = System.Drawing.Color.FromArgb(1, 0, 64), Size = new System.Drawing.Size(145, 20), Location = new Point(30, y_value), Anchor = AnchorStyles.Left, Visible = true }; pic1[i] = new PictureBox { Size = new System.Drawing.Size(400, 20), Location = new Point(2, y_value - 10), Anchor = AnchorStyles.Left, Visible = true, BackColor = Color.FromArgb(y_value/2, 0, 0) }; y_value += 37; } this.Controls.AddRange(l); this.Controls.AddRange(pic1);
相关问答
更多-
只需使用+=运算符添加一个事件处理程序: picOneFaceUpA.MouseClick += new MouseEventHandler(your_event_handler); 要么: picOneFaceUpA.MouseClick += new MouseEventHandler((o, a) => code here); Just add an event handler using the += operator: picOneFaceUpA.MouseClick += new Mouse ...
-
我猜你正在使这件事变得更加复杂。 为了更好地理解和理解,我假定当你说我需要将一个图片框(pictureBox11到pictureBox30)添加到一个数组。 你的意思是你的表单上有30多个PictureBox ,每个PictureBox使用命名约定,每个命名约定都被命名为“pictureBoxX”,其中“X”是1,2,3 ... 30,31。 然后,您想要在表单上获得(连续?)一组“图片框”以使其不可见。 我希望这是正确的。 为了简单地使图片框不可见,我不认为需要数组。 如果名称与“pictureBoxX” ...
-
感谢LarsTech,它已得到修复。 使picturebox在循环内移动, this.controls.add更改为PIC_Map.controls.add和Ore_Area.Parent = PIC_Map; 被删除。 Thanks to LarsTech, it has been fixed. Making the picturebox is moved inside the loop, this.controls.add is changed to PIC_Map.controls.add and O ...
-
我已经测试了你的代码,实际上它们确实重叠了。 (每次迭代时,背景颜色中的红色增加y_value / 2)。 将PictureBox的高度设置为(fe)20,你会发现它们显示得很好: Label[] l = new Label[15]; PictureBox[] pic1 = new PictureBox[15]; int y_value = 47; for (int i = 0; i < 6; ++i) { l[i] = new Label { Text = "Test ...
-
表单容器(PictureBox或Panel)的缩放方法可以用来调整它的大小,所有的子表单都应该使用SizeMode来扩展它们,以便它们遵循缩放。 The scale method of the forms container (PictureBox or Panel) can be used to resize it, all child forms should have the SizeMode to stretch so that they will follow the scaling.
-
添加动态控件(PictureBox),从文本文件中读取位置数据(Add dynamic controls (PictureBox) with position data read from text file)[2021-12-30]
您需要在for循环中移动代码,以创建多个PictureBox 。 目前,您只创建一个实例,为每个blastHole重用它。 尝试这样的事情: private void CreateBlastHole(string[] pointCoordinate) { for (int i = 0; i < pointCoordinate.Length; i++) { PictureBox blastHole = new PictureBox(); blastHole.H ... -
工作范例: Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles PictureBox1.Click, ...., PictureBox50.Click Dim pic As PictureBox = CType(Controls(CType(sender, PictureBox).Name), PictureBox) 'now you have ...
-
您可以通过sender参数访问PictureBox 。 所以试试这个: PictureBox[] txtTeamNames; void YourMethod() { Image myImage = Image.FromFile("image/Untitled6.png"); txtTeamNames = new PictureBox[5]; //The same as your code } void clcikeventhandle(object sen ...
-
隐藏数组图片框c#(Hiding an array picturebox c#)[2022-07-23]
你不是在这里使用错误的长度吗? for (int i = 0; i < picturebox.Length; i++) 应该 for (int i = 0; i < picturebox[0].Length; i++) 当您加载图片框时,您只从索引13开始,因此您需要在13处启动隐藏循环,或检查是否为空。 for (int i = 13; i < picturebox[0].Length; i++) { ... } 要么 for (int i = 0; i < picturebox[0].Length ... -
picturebox数组点击事件(picturebox array click event)[2022-02-03]
您可以像这样添加图片框点击事件: picturebox[0, 0].Click += picturebox_Click; // in your form load event, this is only for one picture box void picturebox_Click(object sender, EventArgs e) { // do whatever you want to do when the picture box is clicked } You can add ...