﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Релиб / Программирование / .NET / VB.NET  / Как правильно обработать события в ToolBar на VB.NET / Latest Posts</title><generator>InstantForum.NET v4.1.4</generator><description>Релиб</description><link>http://www.relib.com/forums/</link><webMaster>robot@relib.com</webMaster><lastBuildDate>Sat, 22 Nov 2008 06:04:56 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Как правильно обработать события в ToolBar на VB.NET</title><link>http://www.relib.com/forums/Topic807188-27-1.aspx</link><description>Прошу большое прощение, что заварил эту кашу.&lt;BR&gt;По непонятным причинам раньше действительно не работало.&lt;BR&gt;Код не сохранен, но вроде все делал именно так, как и вы все советуете.&lt;BR&gt;Потом нашел свое решение через TEG (см. выше)&lt;BR&gt;А сегодня опять попробовал обратиться к бутонам по имени. Все получилось, компилятор молчит.&lt;BR&gt;В чем было дело не знаю.&lt;BR&gt;Странно все это...&lt;BR&gt;Еще раз прошу прощения.</description><pubDate>Mon, 02 Feb 2004 06:02:00 GMT</pubDate><dc:creator>Oleg</dc:creator></item><item><title>RE: Как правильно обработать события в ToolBar на VB.NET</title><link>http://www.relib.com/forums/Topic807188-27-1.aspx</link><description>Не дожидаясь попробовал &lt;BR&gt;[code]&lt;BR&gt;If e.Button Is Me.ToolBarButton1 Then&lt;BR&gt;            MessageBox.Show(&amp;quot;b1&amp;quot;)&lt;BR&gt;        End If&lt;BR&gt;        If e.Button Is Me.ToolBarButton2 Then&lt;BR&gt;            MessageBox.Show(&amp;quot;b2&amp;quot;)&lt;BR&gt;        End If&lt;BR&gt;        If e.Button Is Me.ToolBarButton3 Then&lt;BR&gt;            MessageBox.Show(&amp;quot;b3&amp;quot;)&lt;BR&gt;        End If&lt;BR&gt;[/code]&lt;BR&gt;работает замечательно</description><pubDate>Fri, 30 Jan 2004 15:32:00 GMT</pubDate><dc:creator>mamba2000</dc:creator></item><item><title>RE: Как правильно обработать события в ToolBar на VB.NET</title><link>http://www.relib.com/forums/Topic807188-27-1.aspx</link><description>Сообщение компилятора в студию</description><pubDate>Fri, 30 Jan 2004 15:26:00 GMT</pubDate><dc:creator>mamba2000</dc:creator></item><item><title>RE: Как правильно обработать события в ToolBar на VB.NET</title><link>http://www.relib.com/forums/Topic807188-27-1.aspx</link><description>На такую строку компилятор ругается...</description><pubDate>Fri, 30 Jan 2004 05:48:00 GMT</pubDate><dc:creator>Oleg</dc:creator></item><item><title>RE: Как правильно обработать события в ToolBar на VB.NET</title><link>http://www.relib.com/forums/Topic807188-27-1.aspx</link><description>If e.Button is ToolBarButton1&lt;BR&gt;&lt;BR&gt;Компилятор вроде этого поросил</description><pubDate>Thu, 29 Jan 2004 15:12:00 GMT</pubDate><dc:creator>mamba2000</dc:creator></item><item><title>RE: Как правильно обработать события в ToolBar на VB.NET</title><link>http://www.relib.com/forums/Topic807188-27-1.aspx</link><description>Олегу...&lt;BR&gt;Вы написали:&lt;BR&gt;&amp;quot;Но по моему есть один недостаток.&lt;BR&gt;Кнопки нельзя менять местами.&lt;BR&gt;Можно ли как то обращаться к именам кнопок?&amp;quot;&lt;BR&gt;&lt;BR&gt;В моем примере вы обращаетесь к именам кнопок, хоть возможно и не самым красивым способоб. Вы осуществляете Case не по значениям индексов. Но вам решать.</description><pubDate>Thu, 22 Jan 2004 13:38:00 GMT</pubDate><dc:creator>dilex</dc:creator></item><item><title>RE: Как правильно обработать события в ToolBar на VB.NET</title><link>http://www.relib.com/forums/Topic807188-27-1.aspx</link><description>Алексею...&lt;BR&gt;Чем Ваш пример отличается от выше приведенного?&lt;BR&gt;Я нашел способ, который обрабатывает кнопки, даже если их переставишь местами.&lt;BR&gt;Для этого надо в каждой кнопке прописать TEG&lt;BR&gt;А далее делаем так:&lt;BR&gt;&lt;BR&gt;Private Sub MainToolBar_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles MainToolBar.ButtonClick&lt;BR&gt;&lt;BR&gt;        If e.Button.Tag = &amp;quot;ИмяТэга1&amp;quot; Then&lt;BR&gt;            ........&lt;BR&gt;        elseif e.Button.Tag = &amp;quot;ИмяТэга2&amp;quot; Then&lt;BR&gt;             ..........&lt;BR&gt;        End If&lt;BR&gt;&lt;BR&gt;End Sub&lt;BR&gt;&lt;BR&gt;Мне показалось так будет лучше...&lt;BR&gt;Есть другие мнения?</description><pubDate>Thu, 22 Jan 2004 06:10:00 GMT</pubDate><dc:creator>Oleg</dc:creator></item><item><title>RE: Как правильно обработать события в ToolBar на VB.NET</title><link>http://www.relib.com/forums/Topic807188-27-1.aspx</link><description>Я, например, попробовал во так:&lt;BR&gt;...&lt;BR&gt;        Select Case ToolBar1.Buttons.IndexOf(e.Button)&lt;BR&gt;            Case ToolBar1.Buttons.IndexOf(ToolBarButton1)&lt;BR&gt;                MessageBox.Show(&amp;quot;1&amp;quot;)&lt;BR&gt;            Case ToolBar1.Buttons.IndexOf(ToolBarButton2)&lt;BR&gt;                MessageBox.Show(&amp;quot;2&amp;quot;)&lt;BR&gt;            Case ToolBar1.Buttons.IndexOf(ToolBarButton3)&lt;BR&gt;                MessageBox.Show(&amp;quot;3&amp;quot;)&lt;BR&gt;        End Select&lt;BR&gt;...&lt;BR&gt;&lt;BR&gt;Наверно есть способ и проще :)&lt;BR&gt;С уважением, Алексей.</description><pubDate>Wed, 21 Jan 2004 21:21:00 GMT</pubDate><dc:creator>dilex</dc:creator></item><item><title>RE: Как правильно обработать события в ToolBar на VB.NET</title><link>http://www.relib.com/forums/Topic807188-27-1.aspx</link><description>Да действительно работает.&lt;BR&gt;Но по моему есть один недостаток.&lt;BR&gt;Кнопки нельзя менять местами.&lt;BR&gt;Можно ли как то обращаться к именам кнопок?</description><pubDate>Tue, 20 Jan 2004 06:06:00 GMT</pubDate><dc:creator>Oleg</dc:creator></item><item><title>RE: Как правильно обработать события в ToolBar на VB.NET</title><link>http://www.relib.com/forums/Topic807188-27-1.aspx</link><description>Protected Sub ToolBar1_ButtonClick(ByVal sender As Object, _&lt;BR&gt;ByVal e As ToolBarButtonClickEventArgs)&lt;BR&gt;' Evaluate the Button property of the ToolBarButtonClickEventArgs&lt;BR&gt;' to determine which button was clicked.&lt;BR&gt;   Select Case ToolBar1.Buttons.IndexOf(e.Button)&lt;BR&gt;     Case 0&lt;BR&gt;       MessageBox.Show(&amp;quot;First toolbar button clicked&amp;quot;)&lt;BR&gt;     Case 1&lt;BR&gt;       MessageBox.Show(&amp;quot;Second toolbar button clicked&amp;quot;)&lt;BR&gt;     Case 2&lt;BR&gt;       MessageBox.Show(&amp;quot;Third toolbar button clicked&amp;quot;)&lt;BR&gt;   End Select&lt;BR&gt;End Sub</description><pubDate>Mon, 19 Jan 2004 13:40:00 GMT</pubDate><dc:creator>Olya_G</dc:creator></item></channel></rss>