I am trying to achieve wrapping and unwrapping of text in C1FlexGrid columns in a menu click event handler. The below code works to wrap the text when appropriate menu action is selected. But how I can unwrap the text?
Me.Styles(C1.Win.C1FlexGrid.CellStyleEnum.Normal).WordWrap = True
Me.AllowResizing = AllowResizingEnum.Rows
Me.AutoSizeRows()
I tried the below code but it did not make any difference. Any help is appreciated. Thank you!
Me.Styles(C1.Win.C1FlexGrid.CellStyleEnum.Normal).WordWrap = False
Me.AllowResizing = AllowResizingEnum.None
Me.AutoResize = False
Related
I have a radio button list set up for sorting with 2 possible choices. when the page loads i need to have one of those selected, however it has to be through code rather than manual section in the design screen.
For the first item selected:
myRbl.Items(0).Selected = True
Or the second:
myRbl.Items(1).Selected = True
Simply set their Checked flags to true/false.
rbFirstOne.Checked = True
rbSecondOne.Checked = False
Edit: Oh, radio button list, not just button. Sorry.
On my form, I have 4 RadioButtons, each with its appearance set to Button. In my program, I change each of these RadioButton's ForeColour, BackColour and AutoCheck status, as below:
ARadioButton.AutoCheck = False
ARadioButton.BackColor = Color.FromKnownColor(KnownColor.ControlLightLight)
ARadioButton.ForeColor = Color.FromKnownColor(KnownColor.ControlDark)
However, later on, I reset these properties back to default:
ARadioButton.AutoCheck = True
ARadioButton.BackColor = DefaultBackColor
ARadioButton.ForeColor = DefaultForeColor
My issue is that instead of the entire button being highlighted, only the outside is, as shown in the images below.
Originally:
After changes are made and RadioButtons reset to default using code above:
I know this may seem trivial, but I would like the entire RadioButton to be highlighted when the user clicks on the RadioButton, not just the outside.
Is there a way I could somehow reset this?
Try setting the BackColor property to Color.Transparent
I have created a scrolled window using pyGTK. When I type some text in the scrolled window,that typed text must be written in a file. I have a function which could write to the file. But as and when I go typing some text into the scrolled window that function must be called. If anyone suggest me the solution that would be very helpufull.
import glib, gtk
saveFilePath = 'textview.txt'
isChanged = True
def onBufferChanged(b):
global isChanged
isChanged = True
def onTimeout():
if isChanged:
text = textbuff.get_text(textbuff.get_start_iter(), textbuff.get_end_iter())
open(saveFilePath, 'w').write(text)
isChanged = False
return True ## Continue loop
textview = gtk.TextView()
textbuff = textview.get_buffer()
textbuff.connect('changed', onBufferChanged)
glib.timeout_add_seconds(1, onTimeout)
dialog = gtk.Dialog()
dialog.vbox.pack_start(textview, 1, 1)
dialog.vbox.show_all()
dialog.run()
You should subscribe to change event of text area were you type text and then schedule and execution of function that saves the text to file say each 1 second, so as you type your text would automatically saved. or you could have a background thread that monitors state of that control and save-s it regularly with 1 second delay so that. I think thread way is more correct
I have created my own cutom control in combination of two :
button and a autocompletebox in silverlight.
On a click event of a button i bind the itemsource of a autocompletebox and do this :
acb.ItemsSource = p.ToArray();//list of an object of a class(person)
acb.MinimumPrefixLength = 0;
acb.IsDropDownOpen = true;
And on a textchanged event of a autocompletebox i call a service method to fetch persons based on the search text and do this :
ReferringProvider.ItemsSource = searchproviders;
this.ReferringProvider.tbComboValue.MinimumPrefixLength = 0;
this.ReferringProvider.tbComboValue.IsDropDownOpen = true;
But i lose TextCompletion, the text is not completed with the first item of drop downlist?
Any idea why so? or any suggestions
Please Thanks in advance.
I wrote a blog sometime back on autocomplete text box, but I did not use button. I am not sure you need button to initiate autocomplete. Corrent me I am wrong.
http://csharprambling.wordpress.com/2011/01/26/autocompletebox-to-auto-complete-data-entry/
this is more of an advise thread I guess.
I've been wondering how one could create a button which display "play" when it's not pressed. And then shows "pause" once it's pressed. And visa versa when it's pressed again.
I had a similar problem when trying to create an expand panel button, but that was easy because I could just set a variable to true or false if PanelCollapsed was true.
But in this case I couldn't find any property in a button that I could query.
So I came up with this but I can't help thinking that this is a rather unsmart way of doing it?
If isPlay = True Then
If isPaused = False Then
btnPlay.Image = Image.FromFile("iconPause.png")
isPaused = True
isPlay = False
End If
GoTo Endline
End If
If isPlay = False Then
If isPaused = True Then
btnPlay.Image = Image.FromFile("iconPlay.png")
isPaused = False
isPlay = True
End If
End If
Endline:
How about using only one variable and code like this:
If isPlay Then
btnPlay.Image = Image.FromFile("iconPause.png")
else
btnPlay.Image = Image.FromFile("iconPlay.png")
End If
isPlay = not isPlay
You can use the "Tag" property. Its type is "object" so you can use any object you want, but in your case a string will do:
If Button1.Tag = "Pause" Then
Button1.Image = Image.FromFile("iconPlay.png")
Button1.Tag = "Play"
Else
Button1.Image = Image.FromFile("iconPause.png")
Button1.Tag = "Pause"
End If
Most .NET WinForm controls have a 'Tag' property (a button has one). You can set the Tag to be anything you want. An easy way to do this is to set the 'Tag' property to a boolean with the state of the button.
Just an idea...sure there are many other approaches.
UPDATE:
Otherwise, you can maintain the state of the button in your application as its own member variable. This might have several advantages because you can pass this state to other controls that might need it. The only weakness with this approach is that the state must be maintained separately.
If you have a fairly straight-forward implementation, use the Tag property.
A contrary opinion ...
... while other answers have given you some techniques to achieve your desired result, I'm going to ask you to reconsider your UI design.
Dual state buttons - ones that alternate purpose when clicked - can be a source of user frustation.
Here are two scenarios.
Scenario #1 ... if the users machine is under load (for any reason), there may be a perceptible delay between the users actual click on your button and when your click handler is executed.
Normally the time between click and handler is a few milliseconds or less, but it can run to several seconds. If this happens when the user clicks on a dual state button, they are likely to click the button again. Net effect, when the application catches up, is to toggle on, then immediately off again.
Scenario #2 ... many users habitually double click everything. Even experienced users who've been using computers for years may have this weird habit. When they try to press a dual state button, guess what happens ... the action toggles on, then immediately off again.
There are at least two solutions ...
Solution #1 ... use two buttons, one for "On", one for "Off".
Solution #2 ... write some debouncing code to suppress the effect of a second click if processed immediately (ie: < 75ms) after the first.
I don't personally use Visual Basic, but I do know that Buttons in Windows Forms have a property called 'Tag'. It is of the generic object type, so you can save whatever state you want, and just use casting to get the value back out.
How about using the "Image" property?
Rem form initialization
ImagePlay = Image.FromFile("iconPlay.png")
ImagePause = Image.FromFile("iconPause.png")
Button1.Image = ImagePlay
.
.
.
Rem on button1 click
If Button1.Image = ImagePlay Then
Button1.Image = ImagePause
Else
Button1.Image = ImagePlay
End If