Click here to Skip to main content
15,942,795 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I try to Set ScrollBar Max Value From DataBase Row Count but its not Working So Please Help me in this Problem

And in need scrollBar Show Default in Right Side not in Left Side

What I have tried:

C#
private void DataEntry_Load(object sender, EventArgs e)
{
    AutoDate1();
    fillCombo();
    ScrollBar();
}

private void ScrollBar()
{
    String connstring = ConfigurationManager.ConnectionStrings["Data"].ConnectionString;
    OleDbConnection con = new OleDbConnection(connstring);
    string Query = "select Count(SrNumber) from customer";
    OleDbCommand cd = new OleDbCommand(Query, con);
            
    {
        con.Open();
        int c = Convert.ToInt16(cd.ExecuteScalar());
        hScrollBar1.Maximum = c;
    }
}
Posted
Updated 14-May-20 3:40am
v2
Comments
Richard Deeming 14-May-20 8:25am    
Is this Windows Forms? WPF? Something else?

And you haven't explained what "not working" means.
Amar chand123 14-May-20 8:42am    
In winform and i want my scrollbar bar maximum value show as par my database rows Count i mean for example my database table have 10 Rows then i want if i click right side button in scrollbar then in 10 click my scrollbar position show in last and if i click left button 10 time then scroll position go back in first position but when i use this code scrollbar not work scrollbar never go left or right
Richard MacCutchan 14-May-20 8:44am    
Is your data large enough to exceed the Window size? Scrollbars only appear when all the data is not able to fit the Window. And it is unlikely that your Window is too small for 10 rows.
Amar chand123 14-May-20 8:48am    
i want use my ScrollBar work like Next Perv Button and i Use this Code
private void hScrollBar1_Scroll(object sender, ScrollEventArgs e)
{

if (e.OldValue < e.NewValue)
btnNext.PerformClick();


if (e.OldValue > e.NewValue)
btnPrev.PerformClick();
}
Richard MacCutchan 14-May-20 9:02am    
So what is the problem?

1 solution

Quote:
need scrollBar Show Default in Right Side not in Left Side


So, set this property:
Control.RightToLeft Property (System.Windows.Forms) | Microsoft Docs[^]

Other properties of HScrollBar[^] to set are listed here:
- SmallChange,
- LargeChange,
- Minimum,
- Maximum,
- Value.

As per to me, you're trying to use HScrollBar as ProgressBar[^]. Maybe, you should replace them?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900