我的問題是,我試圖解析一個字符串到System.Drawing.Color。我試圖設置一個簡單的記事本,這裏是我的代碼的一部分:ToString再次回到顏色(Visual Basic 2008)
Private Sub ToolStripMenuItem6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Colorfuente2.Click
Try
Dim cdlg As New ColorDialog
cdlg.ShowDialog()
cdlg.FullOpen = True
cdlg.AnyColor = True
ColorFuente1.Visible = True
Colorfuente2.Visible = False
If Windows.Forms.DialogResult.OK Then
RichTextBox1.ForeColor = cdlg.Color
reciente2.Text = cdlg.Color.ToString 'I've converted this tostring, so that recent colors are shown as text, this is what im trying to reverse
End If
Catch ex As Exception
End Try
End Sub
If Reciente1.Text = "Ninguno" Then
MessageBox.Show("No hay colores recientes", "Bloc de notas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Else : RichTextBox1.ForeColor = Reciente1.Text 'I get the error here, I have to change this text to a System.Drawing.Color.
End If
在此先感謝。
好的,謝謝大家的回答,但現在我又遇到了另外一個問題,每次按「reciente1」時顏色變黑,而不是按鈕文字的顏色。如果有人能給我一個解決方案,請。再次感謝所有提前。 – minimino 2012-03-20 18:36:41