I'm trying to re-create flappybird in Visual studio 2015 c# for a little school project. But for some reason i get this error that i really can't fix. I'm following an tutorial on how to create flappybird, but the one making the tutorial is writing in VB.net Heres the YT Link and under that my code I'm trying to make.
https://www.youtube.com/watch?v=tnjdMbdEzMo
public partial class Form10 : Form
{
int gravity = 1;
int yspeed = 0;
PictureBox[,] Pipe;
public Form10()
{
InitializeComponent();
}
private void gameTimer_Tick(object sender, EventArgs e)
{
int i;
this.yspeed += this.gravity;
bird.Top += this.yspeed;
}
private void inGameKeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Space)
{
this.yspeed = -15;
}
}
private void pausePlayToolStripMenuItem_Click(object sender, EventArgs e)
{
if (gameTimer.Enabled == true)
{
gameTimer.Enabled = false;
}
else
{
if (gameTimer.Enabled == false)
{
gameTimer.Enabled = true;
}
}
}
private void restartToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void startGame_Click(object sender, EventArgs e)
{
if (gameTimer.Enabled == false)
{
gameTimer.Enabled = true;
startGame.Enabled = false;
}
}
private void CreatePipes(int number)
{
int i = 0;
for (i = 0; (i <= number); i++)
{
var temp = new PictureBox();
this.Controls.Add(temp);
temp.Width = 50;
temp.Height = 370;
temp.BorderStyle = BorderStyle.FixedSingle;
temp.BackColor = Color.Red;
temp.Top = 50;
temp.Left = (2 * 200) + 300;
Pipe(i) = temp;
Pipe(i).Visable = true;
}
}
private void Form10_Load(object sender, EventArgs e)
{
gameTimer.Enabled = true;
CreatePipes(1);
}
}
}
The problem you are seeing is in the lines
Pipe(i) = temp;
Pipe(i).Visable = true;
If you are trying to access Pipe as an array, the syntax is Pipe[i], although pipe is a 2d array so it should be Pipe[i,j] Where j is something else.
Also you have misspelled Visible.
Related
Im making a hangman type game. So far it is generating a random word and displays the mystery word. Now I'm trying to allow players to input letter guesses and I need the program to evaluate the letters to see its in the mystery word.
Then if the word is there, and they get it correct, I need to input that letter into the correct position.
I can't figure it out. Does anyone know what I'm doing wrong?
Thanks
public partial class wordGuess : Form
{
private int wrong = 0;
private int currentLetter;
private int currentWord;
private string words;
public wordGuess()
{
InitializeComponent();
}
private void loadwords()
{
//random object//
Random rand = new Random();
//array for words//
List<string> words = new List<string> { "apricot", "sword", "alien", "outerspace", "impossible", "clouds", "crayons", "science" };
int index = rand.Next(words.Count);
String mysteryword = words[index];
foreach (char l in mysteryword)
{
lblRandWord.Text += "*";
}
}
private void picHang_Click(object sender, EventArgs e)
{
}
private void label2_Click(object sender, EventArgs e)
{
}
private void btnLetterG_Click(object sender, EventArgs e)
{
int letter;
letter = Convert.ToChar(txtLetter.Text.Substring(0, 1));
if (wrong == 1)
{
picHeart1.Visible = false;
}
else if (wrong == 2)
{
picHeart1.Visible = false;
picHeart2.Visible = false;
}
else if (wrong == 3)
{
picHeart1.Visible = false;
picHeart2.Visible = false;
picHeart3.Visible = false;
}
else if (wrong == 4)
{
picHeart1.Visible = false;
picHeart2.Visible = false;
picHeart3.Visible = false;
picHeart4.Visible = false;
}
else if (wrong == 5)
{
picHeart1.Visible = false;
picHeart2.Visible = false;
picHeart3.Visible = false;
picHeart4.Visible = false;
picHeart5.Visible = false;
}
else if (wrong == 6)
{
MessageBox.Show("You Lose!");
}
}
private void btnWordG_Click(object sender, EventArgs e)
{
}
private void wordGuess_Load(object sender, EventArgs e)
{
loadwords();
}
}
}
i have POS system to fastfood, created by c# and sql server.
after the payment process show me window "Order Successfully Paid" after clicking to ok return to form ProductsReceiptPreview again,
i want after payment process go to the form main.
this is my code.......
private void lblPayments_Click(object sender, EventArgs e)
{
if (pnlPayments.Height != lbl.Height)
{
pnlPayments.Height = lbl.Height;
btnDone.Text = "DONE";
lbl.Text = "RECEIPT";
btnDone.Image = Resources.done;
Data.Show();
}
else
{
pnlPayments.Height = 394;
btnDone.Text = "RECEIPT";
lbl.Text = "AMOUNT";
btnDone.Image = Resources.receipt;
Data.Hide();
}
}
private void Touch_Click(object sender, EventArgs e)
{
var btn = (Button)sender;
txtCashReceived.Text += btn.Text;
}
private void btnClear_Click(object sender, EventArgs e)
{
if(txtCashReceived.Text.Length >0) txtCashReceived.Text =
txtCashReceived.Text.Remove(txtCashReceived.Text.Length - 1);
}
double totalBill = 0;
private void btnPay_Click(object sender, EventArgs e)
{
if (txtCashReceived.Text.Length > 0 && totalBill <=
Convert.ToInt32(txtCashReceived.Text) && Data.RowCount > 0)
{
int i = 0;
foreach (var rep in ListReports)
{
i++;
var report = new ModelReports();
report.Productname = rep.Productname;
report.TotalSales = rep.TotalSales;
report.TotalTransactions = rep.TotalTransactions;
report.Save();
}
var rpd = new ProductsReceiptPreview(dataReceiptBindingSource,
txtTotal.Text, txtCashReceived.Text, txtChange.Text);
rpd.ShowDialog();
if (i == ListReports.Count)
{
MessageBox.Show("Order Successfully Paid");
}
pnlProducts.Controls.Clear();
pnlCategoryPanel.Visible = false;
dataReceiptBindingSource.Clear();
LoadTables();
btnDone.PerformClick();
}
else
{
MessageBox.Show("Please pay your order.");
txtCashReceived.Text = "0";
}
}
private void btnPay_Click_1(object sender, EventArgs e)
{
if (txtCashReceived.Text.Length > 0 && totalBill <=
Convert.ToInt32(txtCashReceived.Text) && Data.RowCount > 0)
{
int i = 0;
foreach (var rep in ListReports)
{
i++;
var report = new ModelReports();
report.Productname = rep.Productname;
report.TotalSales = rep.TotalSales;
report.TotalTransactions = rep.TotalTransactions;
report.Save();
}
if (i == ListReports.Count)
{
MessageBox.Show("Order Successfully Paid");
txtCashReceived.Text = "0";
}
pnlProducts.Controls.Clear();
pnlCategoryPanel.Visible = false;
dataReceiptBindingSource.Clear();
LoadTables();
btnDone.PerformClick();
}
else
{
MessageBox.Show("Please pay your order.");
}
}
If you call some code from main then it will return to main when the call is finished. In the case of a Form, it's handled on a different thread started from main. The thread will never return back to main in this context. If you are using a click event to do some action and want to call some other code when that happens, then you need to re-design your infrastructure. Look into SOLID development principles and dependency injection.
https://www.codeproject.com/Tips/1033646/SOLID-Principle-with-Csharp-Example
https://simpleinjector.readthedocs.io/en/latest/windowsformsintegration.html
This question already has an answer here:
Interaction between forms — How to change a control of a form from another form?
(1 answer)
Closed 6 years ago.
On one Form, the Quiz form, I have an integer score which keeps track of the user's score. On another Form, the Game Over form, I need to print out the score of the user, but even after hours of me attempting to do so, I still can't manage to do it. I know my code could be improved by A LOT but I just need help to solve this problem and would appreciate it. I just started out on C# and I just wanted to experiment on things.
namespace Quiz_Application
{
public partial class Quiz : Form
{
static Random gen = new Random();
int[] rand = Enumerable.Range(1, 5).OrderBy(q => gen.Next()).ToArray();
int i = 0;
int score = 0;
int[] goArray = new int[1];
public void Question1()
{
questionText.Text = "What is the capital city of Spain?";
optionA.Text = "Barcelona";
optionB.Text = "Madrid";
optionC.Text = "Seville";
optionD.Text = "Zarazoga";
}
public void Question2()
{
questionText.Text = "What is the biggest island on Earth?";
optionA.Text = "Luzon";
optionB.Text = "Singapore";
optionC.Text = "Greenland";
optionD.Text = "Hawaii";
}
public void Question3()
{
questionText.Text = "What is the world's longest river?";
optionA.Text = "Nile";
optionB.Text = "Amazon";
optionC.Text = "Mississipi";
optionD.Text = "Congo";
}
public void Question4()
{
questionText.Text = "Which country is Prague in?";
optionA.Text = "Czech Republic";
optionB.Text = "Slovakia";
optionC.Text = "Austria";
optionD.Text = "Poland";
}
public void Question5()
{
questionText.Text = "What is the diameter of Earth?";
optionA.Text = "6,779km";
optionB.Text = "3,474km";
optionC.Text = "12,742km";
optionD.Text = "8,721km";
}
static void Wait(double sec)
{
Task.Delay(TimeSpan.FromSeconds(sec)).Wait();
}
public Quiz()
{
InitializeComponent();
}
private void Quiz_Load(object sender, EventArgs e)
{
}
public void label1_Click(object sender, EventArgs e)
{
scoreNum.ResetText();
score = 0;
int goScore = goArray[0];
this.Hide();
Form1 f1 = new Form1();
f1.ShowDialog();
this.Close();
}
private void optionClick(object sender, EventArgs e)
{
startButton.Enabled = false;
Button l = (Button)sender;
int[] goArray = new int[1];
goArray[0] = score;
if (l.Text == "Madrid" || l.Text == "Greenland" || l.Text == "Amazon" || l.Text == "Czech Republic" || l.Text == "12,742km")
{
score++;
scoreNum.Text = score.ToString();
correctOrWrong.Image = Resources.correct; Wait(1); correctOrWrong.Image = null;
}
else
{
correctOrWrong.Image = Resources.wrong; Wait(1); correctOrWrong.Image = null;
}
l.BackColor = System.Drawing.Color.Maroon;
optionA.Enabled = false; optionB.Enabled = false; optionC.Enabled = false; optionD.Enabled = false;
startButton.Enabled = true;
}
private void startButton_Click(object sender, EventArgs e)
{
Button b = (Button)sender;
optionA.Enabled = true; optionB.Enabled = true; optionC.Enabled = true; optionD.Enabled = true;
if (i == 5)
{
scoreNum.ResetText();
score = 0;
int goScore = goArray[0];
b.Text = "Finish";
this.Hide();
Game_Over go = new Game_Over();
go.ShowDialog();
this.Close();
}
try
{
switch (rand[i])
{
case 1:
Question1();
i++;
break;
case 2:
Question2();
i++;
break;
case 3:
Question3();
i++;
break;
case 4:
Question4();
i++;
break;
case 5:
Question5();
i++;
break;
case 6:
Wait(2);
this.Hide();
Game_Over go = new Game_Over();
go.ShowDialog();
this.Close();
break;
}
if (i == 5)
{
b.Text = "Finish";
}
}
catch { }
if (i != 5)
b.Text = "Next";
b.Enabled = false;
}
private void mouseEnter(object sender, EventArgs e)
{
this.Cursor = Cursors.Hand;
}
private void mouseLeave(object sender, EventArgs e)
{
this.Cursor = Cursors.Default;
}
public int get(int i)
{
return i;
}
}
and my Game Over form
namespace Quiz_Application
{
public partial class Game_Over : Form
{
public Game_Over()
{
InitializeComponent();
}
private void Game_Over_Load(object sender, EventArgs e)
{
Quiz q = new Quiz();
}
private void playAgain_Click(object sender, EventArgs e)
{
Quiz q = new Quiz();
this.Hide();
q.ShowDialog();
this.Close();
}
private void mainMenu_Click(object sender, EventArgs e)
{
Form1 f1 = new Form1();
this.Hide();
f1.ShowDialog();
this.Close();
}
}
Create a public class and store the value in it, you can access the value across the code.
class Globals
{
public static int Score = 0;
}
// In the window you can assign value for the variable like below
Globals.Score=<Your score>;
In the Game_Over form, add a label to display the score if you haven't done so already. I will call it myScoreLabel Then, when you show the form i.e. here:
case 6:
Wait(2);
this.Hide();
Game_Over go = new Game_Over();
go.ShowDialog();
this.Close();
break;
add this line before go.ShowDialog:
go.yourScoreLabel.Text = "Score: " + score.ToString();
I am currently working on a platformer in C#,VS 2015
The problem i have encountered is:when i press the left/right arrow,the background moves behind the player in the opposite direction,and this happens using a timer(which cannot be set to a value lower than 1 milisecond).
Because the timer is limited to 1 milisecond,the background moves laggy,and i would like to solve this :D
Here is the code
public Form1()
{
InitializeComponent();
}
Bitmap back;
Bitmap bobright;
Bitmap bobleft;
Bitmap bobimage;
Bitmap exit;
Point boblocation = Point.Empty;
Point exitlocation = Point.Empty;
float offSet = 0, vit;
int acc_secunde, acc_secunde_max = 30;
bool left = false, right = false;
private void button1_Click(object sender, EventArgs e)
{
Application.Exit();
}
public void Game()
{
int imageNumber = panel1.Width / back.Width + 3;
using (Bitmap frame = new Bitmap(panel1.Width, panel1.Height))
{
using (Graphics graph = Graphics.FromImage(frame))
{
for (int i = 0; i < imageNumber; i++)
{
graph.DrawImage(back, offSet/2 % back.Width + i * back.Width - back.Width, 0);
}
graph.DrawImage(bobimage, boblocation);
graph.DrawImage(exit,exitlocation);
}
using (Graphics graph = panel1.CreateGraphics())
{
graph.DrawImage(frame, Point.Empty);
}
}
}
private void Form1_Load(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Maximized;
back = Properties.Resources.back;
bobleft = Properties.Resources.bobleft;
bobright = Properties.Resources.bobright;
bobimage = bobright;
exit = Properties.Resources.Exit;
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
boblocation.X = panel1.Width / 2 - bobimage.Width / 2;
boblocation.Y = 210;
exitlocation.X = panel1.Width - exit.Width - 10;
exitlocation.Y = 5;
if (left)
{
offSet = offSet + acc_secunde;
bobimage = bobleft;
}
if(right)
{
bobimage = bobright;
offSet = offSet - acc_secunde;
}
Game();
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if(e.KeyCode == Keys.Left)
{
acceleratie.Start();
left = true;
}
if(e.KeyCode == Keys.Right)
{
acceleratie.Start();
right = true;
}
}
private void Form1_KeyUp(object sender, KeyEventArgs e)
{
if(e.KeyCode == Keys.Left)
{
acceleratie.Stop();
deacceleratie.Start();
}
if(e.KeyCode == Keys.Right)
{
acceleratie.Stop();
deacceleratie.Start();
}
}
private void Form1_MouseUp(object sender, MouseEventArgs e)
{
}
private void deacceleratie_Tick(object sender, EventArgs e)
{
if(acc_secunde > 0)
acc_secunde = acc_secunde - acc_secunde_max / 3;
if (acc_secunde <= 0)
{
deacceleratie.Stop();
if (right == true)
right = false;
if (left == true)
left = false;
acc_secunde = 0;
}
}
private void acceleratie_Tick(object sender, EventArgs e)
{
if(acc_secunde< acc_secunde_max)
acc_secunde+=2;
}
private void Form1_MouseClick(object sender, MouseEventArgs e)
{
}
private void panel1_MouseUp(object sender, MouseEventArgs e)
{
Point mousePt = new Point(e.X, e.Y);
if (mousePt.X > panel1.Width - exit.Width - 10 && mousePt.X < panel1.Width - 10 && mousePt.Y > panel1.Top + 10 && mousePt.Y < panel1.Top + 10 + exit.Height)
Application.Exit();
}
}
}
I have created a code for my combobox, that can search addresses in a very large table on Sql Server with the help of stored procedure (i'm working with Entity framework). My stored procedure returns 10 hits and my code fills the combobox with search results. For doing this I'm using BackgroundWorker.
But here I'm now having big problems:
- although the combobox is filled with my search results, it always has the first item selected. Even if I type in only a letter, the whole text gets selected;
After that searching for the address doesn't work anymore. It searches only among these 10 results and I'm having no idea how to solve this. Here is my whole code, that causes me problems:
public String searchedItem = "";
public delegate void DelegateUpdateComboboxSelection(ComboBox myCombo,string value,int count);
BackgroundWorker m_bgworker = new BackgroundWorker();
static AutoResetEvent resetWorker = new AutoResetEvent(false);
m_bgworker.WorkerSupportsCancellation = true;
m_bgworker.DoWork += new DoWorkEventHandler(FillComboboxBindingList);
m_bgworker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(m_bgworker_RunWorkerCompleted);
BindingList<spIskalnikNaslovi_Result1> m_addresses = new BindingList<SP_Result1>();
void m_bgworker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
int count = (int)((object[])e.Result)[0];
string value = (string)((object[])e.Result)[1];
ComboBox myCombo = (ComboBox)((object[])e.Result)[2];
DelegateUpdateComboboxSelection ndelegate = new DelegateUpdateComboboxSelection(UpdateComboSelection);
if (this.InvokeRequired)
{
Invoke(ndelegate, new object[] {myCombo, value, count});
return;
}
else
{
UpdateComboSelection(myCombo, value, count);
return;
}
}
private void UpdateComboSelection(ComboBox myCombo, String value, int count)
{
myCombo = comboBox9;
myCombo.DataSource = m_addresses;
searchedItem = myCombo.Text;
if (count > 0)
{
myCombo.SelectionStart = value.Length;
myCombo.SelectionLength = searchedItem.Length - value.Length;
myCombo.DroppedDown = true;
}
else
{
myCombo.DroppedDown = false;
myCombo.SelectionStart = value.Length;
}
}
public void FillComboboxBindingList(object sender, DoWorkEventArgs e)
{
if (m_bgworker.CancellationPending)
{
resetWorker.Set();
e.Cancel = true;
return;
}
else
{
string value = (String)((Object[])e.Argument)[0];
List<SP_Result1> result;
result = _vsebina.SP_searcher(value).ToList<SP_Result1>();
m_addresses = new BindingList<SP_Result1>();
foreach (SP_Result1 rez in result)
{
if (m_addresses.Contains(rez))
{
continue;
}
else
{
m_addresses.Add(rez);
}
}
foreach (SP_Result1 r in m_addresses.ToArray())
{
if (!result.Contains(r))
{
m_addresses.Remove(r);
}
}
e.Result = new object[] { rezultat.Count, vrednost, null };
return;
}
}
private void comboBox9_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Back)
{
int searchStart = comboBox9.SelectionStart;
if (searchStart > 0)
{
searchStart--;
if (searchStart == 0)
{
comboBox9.Text = "";
}
else
{
comboBox9.Text = comboBox9.Text.Substring(0, searchStart + 1);
}
}
else
{
searchStart = 0;
}
e.Handled = true;
}
}
private void comboBox9_Enter(object sender, EventArgs e)
{
comboBox9.SelectionStart = 0;
comboBox9.SelectionLength = 0;
}
private void comboBox9_Click(object sender, EventArgs e)
{
comboBox9.Text = "";
}
private void comboBox9_KeyPress(object sender, KeyPressEventArgs e)
{
Search();
}
public void Search()
{
if (comboBox9.Text.Length < 4)
{
return;
}
else
{
if (m_bgworker.IsBusy)
{
m_bgworker.CancelAsync();
m_bgworker = new BackgroundWorker();
m_bgworker.WorkerSupportsCancellation = true;
m_bgworker.DoWork += new DoWorkEventHandler(FillComboboxBindingList);
m_bgworker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(m_bgworker_RunWorkerCompleted);
}
m_bgworker.RunWorkerAsync(new object[] { comboBox9.Text, comboBox9 });
}
}
Maybe can someone enlighten me, what I'm doing wrong. This is first time, that I'm using BackgroundWorker. I have no idea, how
to achieve "search as you type" with combobox in any other way, because my datatable with addresses is quite large (million records).
Thanks in advance for any kind of help or code example.
Vladimir
Edit 1:
Ok, here is my code, before I have used BackGroundWorker. It worked, but it searches very very slow (it can take up to 10 seconds):
private void comboBox9_TextChanged(object sender, EventArgs e)
{
if (comboBox9.Text.Length < 4)
{
return;
}
else
{
FillCombobox(comboBox9.Text, comboBox9);
}
}
public void FillCombobox(string value, ComboBox myCombo)
{
List<spIskalnikNaslovi_Result1> result;
result = _vsebina.spIskalnikNaslovi1(value).ToList();
if (result.Count() > 0)
{
myCombo.DataSource = result;
myCombo.ValueMember = "HS_MID";
myCombo.DisplayMember = "NASLOV1";
var searchedItem = myCombo.Items[0].ToString();
myCombo.SelectionStart = value.Length;
myCombo.SelectionLength = searchedItem.Length - value.Length;
myCombo.DroppedDown = true;
}
else
{
myCombo.DroppedDown = false;
myCombo.SelectionStart = value.Length;
}
return;
}
Is there a way to speed this up without having backgroundworker?
make a button you will call searchbutton
and in click_event of this button call your search() method that run your backgroundworker
that fill the combobox
clear you key_press event of your combobox and it will work
the mistake is you key_press event that call every key stroke happening your search method
so retrieve it
You should get your items in a list, use that list to populate your combobox.
then set AutoCompleteMode property value to Suggest or Append or SuggestAppend and set AutoCompleteSoucre property value to ListItems.
For "Search as you Type", which is actually "Filter as you Type" more than search, you need to implement the OnKeyDown or KeyPressed event.
What you would do is take the search string, which is the current text at the time of the event, then filter the master list using that string. Normally one would use "Starts With" for the filtering, but you could also simply use "Contains". Then you live update the contents of the box with the results from the filter. This is accomplished by changing and refreshing the Datasource.
Here is my final solution without BackGroundWorker. It works quick with my large table, and is upgraded for using a stored procedure on SQL Server (if you use Entity Framework). I use Timer to make sure the user can find a value, that he is searching.
Here you can see the original solution, that I found on this site (thanks to Max Lambertini and algreat for the idea and working concept):
C# winforms combobox dynamic autocomplete
My solution:
private bool _canUpdate = true;
private bool _needUpdate = false;
List<spIskalnikNaslovi_Result1> dataFound;
private void comboBox12_TextChanged(object sender, EventArgs e)
{
if (_needUpdate)
{
if (_canUpdate)
{
_canUpdate = false;
refreshData();
}
else
{
restartTimer();
}
}
}
private void comboBox12_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Back)
{
int searchStart = comboBox12.SelectionStart;
if (searchStart > 0)
{
searchStart--;
if (searchStart == 0)
{
comboBox12.Text = "";
}
else
{
comboBox12.Text = comboBox12.Text.Substring(0, searchStart + 1);
}
}
else
{
searchStart = 0;
}
e.Handled = true;
}
}
private void comboBox12_TextUpdate(object sender, EventArgs e)
{
_needUpdate = true;
}
private void timer1_Tick(object sender, EventArgs e)
{
_canUpdate = true;
timer1.Stop();
refreshData();
}
private void refreshData()
{
if (comboBox12.Text.Length > 1)
{
FillCombobox(comboBox12.Text, comboBox12);
}
}
private void restartTimer()
{
timer1.Stop();
_canUpdate = false;
timer1.Start();
}
private void FillCombobox(string value, ComboBox myCombo)
{
dataFound = _vsebina.spIskalnikNaslovi1(value).ToList();
if (dataFound.Count() > 0)
{
myCombo.DataSource = dataFound;
myCombo.ValueMember = "HS_MID";
myCombo.DisplayMember = "NASLOV1";
var searchedItem = myCombo.Items[0].ToString();
myCombo.SelectionStart = value.Length;
myCombo.SelectionLength = searchedItem.Length - value.Length;
myCombo.DroppedDown = true;
return;
}
else
{
myCombo.DroppedDown = false;
myCombo.SelectionStart = value.Length;
return;
}
}