Reputation: 357
I have this:
private void radioButton34_CheckedChanged(object sender, EventArgs e)
{
if (radioButton.Checked == true)
{ //blah}
}
private void radioButton35_CheckedChanged(object sender, EventArgs e)
{
if (radioButton.Checked == true)
{ //blah}
}
but they are 100 buttons (no joke) I wanna replace 'radioButton.Checked' with 'radioButtonX.Checked' in the sequence, for every radioButton.Checked that he finds, where X starts in 34, and ends in 100
Is it possible? What if i want X to start in 20 or a anyother number? (noob here)
Upvotes: 0
Views: 221
Reputation: 868
1/ 1-Step solution
Hit replace (⌥⌘F or ctrl+shift+F (I guess) or Find→Replace...
).
Search for (?<=radioButton)(\d+)(_CheckedChanged(?:\n|.)*?radioButton)
with RegEx (.*
) activated. (see below for explanation on the regex)
And replace with: \1\2\1
RegEx:
(?<=radioButton)
: the string start with radioButton(\d+)
: it is followed by a bunch of numbers, we store this in \1(_CheckedChanged(?:\n|.)*?radioButton)
: it is itself followed by _CheckedChange, any number of characters and newLine characters, and radioButton, this is stored in \22/ 2-Step Solution
A little more general solution (not limited to a 2-digit number).
Launch a search: (⌘F or Ctrl+F or Find→Find...
). Make sure the Regex box is selected on the left (.*
).
Search for: (?<=radioButton)\d+(?=_CheckedChanged)
(?<=radioButton)
: radioButton should be in front of what you search\d+
is any digit, but at least one(?=_CheckedChanged)
: the number has to be followed by _CheckedChangedSearch for all these. Copy the results. Move all your cursors to the desired location, and paste.
If you have any question :-)
PS:
Upvotes: 3
Reputation: 33
This may be a stupid response, but off the top of my head, it should work if _CheckedChanged isn't used anywhere else.
I just realised you said 100. Obviously the above idea would only work if X is the same number of digits. You'll have to correct the 100th after.
There is surely a better way, but that should do the job I guess. 100 radio buttons!?
Upvotes: 2