【发布时间】:2014-04-04 07:48:18
【问题描述】:
我正在开发一个依赖webbrowser winform 组件的浏览器。
我使用xtratabcontrol 来浏览标签(DevExpress 组件),它的标签中有关闭按钮。
我正在尝试实现 Internet Explorer(其最新版本)在关闭选项卡时所做的事情;其他标签被扩展(它们的宽度增加)以达到鼠标位置(在标签后关闭标签而不移动鼠标)
这是我添加的代码(在关闭按钮单击事件中)
Point cursor = MousePosition;
int x = cursor.X;
int count = browserTabControl.TabPages.Count -1;// I don't want to include the last tab (which opens another tabs)
int width = x / count;
for (int i = 0; i < browserTabControl.TabPages.Count -1 ; i++)
browserTabControl.TabPages[i].TabPageWidth = width;
我还尝试在删除最后一个选项卡之前获取选项卡的整个宽度,然后将其划分为新选项卡计数,并将结果设置为每个选项卡:
int current_width = (browserTabControl.TabPages.Count - 1) * browserTabControl.TabPages[0].TabPageWidth;
//..............some code removing the last tab (actually the tab before the last tab)
//after removing the last tab
int count = browserTabControl.TabPages.Count - 1;
int width = current_width / count;
for (int i = 0; i < browserTabControl.TabPages.Count - 1; i++)
browserTabControl.TabPages[i].TabPageWidth = width;
第一个代码结果
第二个代码结果:
问题可能是当我将 int/int 相除时,我失去了其余的除法,我可以得到一个 double 结果,但 TabPageWidth 是 int。
【问题讨论】:
标签: c# devexpress tabcontrol