我正在開發一個依靠webbrowser
winform組件的瀏覽器。如何增加標籤寬度到鼠標位置
我使用xtratabcontrol
爲了與在其選項卡中具有關閉按鈕的選項卡(DevExpress組件)衝浪。
我正試圖在關閉標籤時實現什麼是Internet Explorer(它的最後一個版本)。其他標籤延伸(其寬度增加)到達鼠標poisiton(以允許卡之後,關閉選項卡不移動鼠標)
這是我添加的代碼(在關閉按鈕點擊事件)
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我失去了分裂的其餘,我可以得到雙重的結果,但TabPageWidth是int。
它不適合我的目的,我也有一個標籤,我不想擴展它(上圖中的最後一個標籤),另外,它不會將標籤擴展到鼠標位置;我需要移動鼠標關閉... –
IMO最後一個不應該是一個選項卡,它應該是一個'CustomHeaderButton'來添加一個新選項卡。 PS:我的答案是解決你的問題的另一種方式,即開箱即用的東西不完全是你問的。 –
如果我刪除最後一個選項卡並將其轉換爲CustomHeaderButton它會工作嗎?我可以把按鈕放在同一個地方嗎? –