这里发生的是当窗体打开时,它显示contextMenu并使用dataSet1的值显示其上的DataGridView.但是,当我单击按钮更改Grid的DataSource时,它不会显示dataSet2的记录.
private void Form1_Load(object sender, EventArgs e)
{
SetDataSource(dataSet1);// A populated DataSet
}
protected void SetDataSource(DataSet ds)
{
dataGridView1.DataSource = ds;
ToolStripControlHost tsHost = new ToolStripControlHost(dataGridView1);
contextMenuStrip1.Items.Clear();
contextMenuStrip1.Items.Add(tsHost);
contextMenuStrip1.Show(textBox1, 0, 27);
}
private void button1_Click(object sender, EventArgs e)
{
SetDataSource(dataSet2);// Another populated DataSet
}
Run Code Online (Sandbox Code Playgroud)
我尝试在我的表单中添加另一个DataGridView控件(dataGridView2),但这次我没有把它放在ToolStripControlHost中,我没有将它添加到contextMenuStrip1.
dataGridView1.DataSource = ds;
dataGridView2.DataSource = ds; // <-- Parent of this is the Form1, the control is not added in the contextMenuStrip.
ToolStripControlHost tsHost = new ToolStripControlHost(dataGridView1);
contextMenuStrip1.Items.Clear();
contextMenuStrip1.Items.Add(tsHost);
contextMenuStrip1.Show(textBox1, 0, 27);
Run Code Online (Sandbox Code Playgroud)
加载Form1时,contextMenuStrip1弹出窗口,dataGridView1作为项添加到它,使dataGridView1在窗体中消失,dataGridView2只保留在Form1中.
当我打button1 …
我有两个问题.
1)我找到了一些关于如何平滑地进行控件滚动的代码.
大.但是它会覆盖WndProc方法,所以要使用它,我必须撕掉我在设计时删除窗体上的FlowLayoutPanel,子类FlowLayoutPanel,然后最终实例化我的新类并手动创建所有属性并更改所有引用控制为this.Controls ["ControlName"].(或者我想我可以创建一个类级变量,它本质上就是控件最初的变量,但是当它没有在任何地方声明时,它们如何让你使用intellisense?)
所以现在我只是想知道实际上是否有运行方式来实现它.
我可以做一些简单的事情,其中MainPanel是控件的名称:
MainPanel = (SmoothScrollingFlowLayoutPanel)MainPanel
Run Code Online (Sandbox Code Playgroud)
它不是那么容易,可以吗?即便如此,它仍然很烦人,因为我仍然必须拥有子类(这可能是一个很好的设计决定,但我想要一次性的自由).那么可以将代码放入FlowLayoutPanel的父代,如下所示:
private Delegate void WndProcHandler(ref Message m);
private WndProcHandler w;
public void SomeCode() {
w = MainPanel.WndProc; // get reference to existing wndproc method
MainPanel.WndProc = WndProcSmoothScroll; //replace with new method
}
private void WndProcSmoothScroll(ref Message m) { // make smooth scrolling work
if (
(m.Msg == WM_HSCROLL || m.Msg == WM_VSCROLL)
&& (((int)m.WParam & 0xFFFF) == 5)
) {
m.WParam = (IntPtr)(((int)m.WParam & ~0xFFFF) | 4);
}
if …Run Code Online (Sandbox Code Playgroud) 我明白如何将:controller,:action, :etc为URL.我正在寻找相反的方法,如何从URL中找到rails路由器将调用的操作?
编辑:我刚刚意识到这个问题可能更适合ServerFault.主持人请将其移动,而不是复制它?谢谢.
我已经检查了php-info,并且Postgresql扩展已经存在(pg_connect()未定义).我也可以使用psqllocalhost 连接到postgresql (我已经适当地编辑了我的pg_hba.conf文件).这是不起作用的代码:
<?php
$dbconn = pg_connect("host=localhost port=5432 dbname=mydb user=myuser password=mypass") or die('Could not connect: ' . pg_last_error());
?>
Run Code Online (Sandbox Code Playgroud)
此代码只会导致浏览器中显示"无法连接:".
我检查了我的apache日志,这是相关的错误消息:
PHP Warning: pg_connect() [<a href='function.pg-connect'>function.pg-connect</a>]:
Unable to connect to PostgreSQL server: could not connect to server: Permission
denied\n\tIs the server running on host "localhost" and accepting\n\tTCP/IP
connections on port 5432?
Run Code Online (Sandbox Code Playgroud)
我该如何修复/调试这个?
编辑:我在Centos 5.4 btw.
哦干草那里,没见到你.我想知道是否有更好,更有效的方式来格式化java中的标签,面板和按钮,然后我在下面做了.这是我的代码,我想将欢迎,日期和按钮全部放在不同的行上.这样做的唯一合理方法是创建空白标签,对吧?
private void GeneralTab() {
generalPanel = new JPanel(new FlowLayout());
String currentTime = SimpleDateFormat.getInstance().format(
Calendar.getInstance().getTime());
generalPanel.add(new JLabel(" "));
generalPanel.add(new JLabel(" "));
generalPanel.add(new JLabel(" "));
generalPanel.add(new JLabel(" "));
generalPanel.add(new JLabel(" "));
generalPanel.add(new JLabel(" "));
generalPanel.add(new JLabel(" "));
generalPanel.add(new JLabel(" "));
generalPanel.add(new JLabel(" "));
generalPanel.add(new JLabel(" "));
generalPanel.add(new JLabel(" "));
generalPanel.add(new JLabel(" "));
generalPanel.add(new JLabel("WELCOME "));
generalPanel.add(new JLabel(" "));
generalPanel.add(new JLabel(" "));
generalPanel.add(new JLabel(" "));
generalPanel.add(new JLabel(" "));
generalPanel.add(new JLabel(" "));
generalPanel.add(new JLabel(" "));
generalPanel.add(new JLabel(" "));
generalPanel.add(new JLabel(" "));
generalPanel.add(new JLabel(" …Run Code Online (Sandbox Code Playgroud) 我有两个文件:
#include "osd.h"
#include "osdadd.h"
#include <stdio.h>
struct TextSize tsize;
char buff[50];
void hud_draw_lin_compass(int cx, int cy, int tick_maj, int tick_min, int range, int heading)
{
.. important code that uses buff ..
}
Run Code Online (Sandbox Code Playgroud)
#include "hudwidgets.h"
#include "hud.h"
#include "osd.h"
#include "osdadd.h"
.. some code ..
void hud_rc_plane_single_frame()
{
fill_mem(0x0000);
if((frame / 50) % 2 == 0)
{
get_next_warning(buff);
}
.. some more code ..
}
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是,当我尝试编译它时,编译器抱怨没有buff定义,但是当我尝试定义它时,链接器会抱怨两个buff变量.第二十二条军规.为此,我问了两个问题:
如何解决这个问题;
如果可以使用相同的变量从而节省内存,因为只需要分配一个变量(使用内存受限的微控制器).
我有一些代码因为一些错误的分号而触发了语法错误.如果这是在命令行上运行,我会用分隔符来解决这个问题.不幸的是,jdbc4驱动程序似乎没有识别分隔符.无论如何要让它运行?
delimiter |
CREATE TRIGGER obs_update BEFORE UPDATE ON obs
FOR EACH ROW
BEGIN
IF OLD.voided = 0 AND NEW.voided = 1 THEN
DELETE FROM clinic_obs WHERE id = OLD.obs_id;
ELSE
UPDATE clinic_obs SET clinic_obs.revision_token = NOW()
WHERE NEW.obs_id = clinic_obs.id;
END IF;
END;
|
delimiter ;
Run Code Online (Sandbox Code Playgroud) 我最近发现需要在C++中使用编译时断言来检查两种类型的大小是否相等.
我在网上发现了以下宏(声称来自Linux内核):
#define X_ASSERT(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
Run Code Online (Sandbox Code Playgroud)
我喜欢这样:
X_ASSERT(sizeof(Botan::byte) != sizeof(char));
Run Code Online (Sandbox Code Playgroud)
这让我好奇-虽然这工作,是有一个更清洁的方式来做到这一点?(显然,不止一种方式)某些方法有优缺点吗?
c# ×2
c++ ×2
c ×1
centos ×1
directshow ×1
formatting ×1
iphone ×1
java ×1
jdbc ×1
methods ×1
mysql ×1
objective-c ×1
overriding ×1
php ×1
postgresql ×1
routing ×1
runtime ×1
swing ×1
triggers ×1
winforms ×1