2013-11-21 121 views
0

我有这个RadioButtonList包含很多项目,所以我需要添加一个垂直滚动条。这是我添加项目在RadioButtonList添加滚动条到RadioButtonList

var Meals = Factory.Meals.List(); 
    var MealVotes = Factory.MealVotes.List(item => item.VoteDate == DateTime.Today); 
    var MealVote = Factory.MealVotes.List(item => item.VoteDate == DateTime.Today && item.UserId == Instance.CurrentUserId).ToList().FirstOrDefault(); 

     foreach (var meal in Meals) 
     { 
      mealVotes = 0; 
      TotalVotes = 0; 

      foreach (var mealVote in MealVotes) 
      { 
       if (meal.Id == mealVote.MealId) 
       { 
        mealVotes++; 
       } 

       TotalVotes++; 
      } 

      if (TotalVotes > 0) 
      { 
       Width = (100M/TotalVotes) * mealVotes; 
      }; 

      VoteMealRadioButtonList.Items.Add(
       new ListItem(
        meal.Title + " " + mealVotes + 
        @"<div style=""height: 10px; width:130px;"">" + 
         @"<a style=""float: left; width: 30px""></a>" + 
         @"<div style=""float: left; height: 10px; width:" + Width + @"px; background: DarkCyan;""></div>" + 
        "</div>", 
        meal.Id.ToString() 
       ) 
      ); 
     } 

     VoteMealRadioButtonList.SelectedValue = MealVote.MealId.ToString(); 

它看起来像这样的代码:

enter image description here

不要担心名单和膳食名称(这是我的母语)。如果List中充满了这样的餐食量,这将不会成为问题,但会有50餐或类​​似的东西,所以这就是为什么我想添加一个垂直滚动条。

无论如何我可以添加一个滚动条?

回答

1

为什么你不把radiobuttonlist放入div并将滚动条添加到这个div?

+0

RadioButtonList已经在div中。我没有意识到我可以先滚动到div。谢谢,现在解决了:) – etritb